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 |
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 |
All times are GMT +1. The time now is 06:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com