PC Review


Reply
Thread Tools Rate Thread

Building A string

 
 
dmoney
Guest
Posts: n/a
 
      1st Oct 2009
I have a need to build a string that is a concantanation of and undetermined
amonunt of addresses. For example my code finds an initial address of a cell
and stores it to a variable. my code then performs a find next to get the
next address and i would like to build on to the initial string for every new
address with a desired final string something similar to this "=$a$13 & "+" &
$a$23 & "+" & $a$613 & "+" & $c$733 ...

basically im trying to build a string to put in a cell that will add the
values of certain cells based on a condition

your help is greatly appreciated

 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      1st Oct 2009
The below macro will take you in the right direction..

Sub Macro1()
Dim varFound As Variant, varSearch As Variant
Dim strAddress As String, strOutput As String

varSearch = "dmoney"
With Worksheets("Sheet1").UsedRange
Set varFound = .Find(varSearch, LookIn:=xlValues)
If Not varFound Is Nothing Then
strAddress = varFound.Address
Do
Set varFound = .FindNext(varFound)
strOutput = strOutput & "+" & varFound.Address
Loop While Not varFound Is Nothing And _
varFound.Address <> strAddress
End If
End With
MsgBox "=" & Mid(strOutput, 2)
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"dmoney" wrote:

> I have a need to build a string that is a concantanation of and undetermined
> amonunt of addresses. For example my code finds an initial address of a cell
> and stores it to a variable. my code then performs a find next to get the
> next address and i would like to build on to the initial string for every new
> address with a desired final string something similar to this "=$a$13 & "+" &
> $a$23 & "+" & $a$613 & "+" & $c$733 ...
>
> basically im trying to build a string to put in a cell that will add the
> values of certain cells based on a condition
>
> your help is greatly appreciated
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with sql string building Jack Microsoft Access Queries 2 13th Nov 2009 11:14 PM
Building a SQL string DZ Microsoft Access VBA Modules 1 18th Sep 2008 04:44 AM
building a string Dave Microsoft Access VBA Modules 3 18th May 2008 09:46 PM
Is KeyValuePair<string,string>.ToString intended as serialization building block? Steve Richter Microsoft C# .NET 2 7th May 2007 09:34 PM
Building an SQL query string to include "&" as part of string Paul Microsoft Access VBA Modules 4 27th Aug 2003 09:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:52 AM.