Opv
04-30-2010, 01:26 PM
The following script in effect concatenates the values from about eight cells:
Dim termInfo As String
termInfo = .Range(rng.Address).Offset(0, 6).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 7).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 8).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 9).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 10).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 11).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 12).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 13).Value
I am attempting to use the above script to come with a consolidated string with which to populate another cell. While this script does what it is designed to do, my problem is that some of the cells are likely going to be blank, so I am getting a lot of ", , ," in the resulting string.
I've also tried a For Next loop with i = 6 to 13, attempting to loop through the desired cells but I'm still getting the superfluous commas. I'm looking for a way to do the above but only include populated cells in the resulting string, with an "," between each populated cell.
Thanks,
Opv
Dim termInfo As String
termInfo = .Range(rng.Address).Offset(0, 6).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 7).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 8).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 9).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 10).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 11).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 12).Value
termInfo = termInfo & ", " & .Range(rng.Address).Offset(0, 13).Value
I am attempting to use the above script to come with a consolidated string with which to populate another cell. While this script does what it is designed to do, my problem is that some of the cells are likely going to be blank, so I am getting a lot of ", , ," in the resulting string.
I've also tried a For Next loop with i = 6 to 13, attempting to loop through the desired cells but I'm still getting the superfluous commas. I'm looking for a way to do the above but only include populated cells in the resulting string, with an "," between each populated cell.
Thanks,
Opv