Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Building A string

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Building A string

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building SQL-string with vba Jan T.[_3_] Excel Programming 2 June 11th 08 06:17 PM
String Building for Where Clause in query [email protected] Excel Programming 2 June 25th 07 10:54 PM
String Building for Where Clause in Query [email protected] Excel Programming 0 June 7th 07 12:43 PM
Building a string [email protected] Excel Programming 3 September 25th 06 09:53 AM
Building Sum by Matching String guruk Excel Discussion (Misc queries) 1 July 10th 06 12:55 PM


All times are GMT +1. The time now is 06:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"