Macro - concatenated cells until if finds a blank cell
Closed
PFMONEY
TrowaD
- Posts
- 1
- Registration date
- Monday January 14, 2013
- Status
- Member
- Last seen
- January 14, 2013
TrowaD
- Posts
- 2880
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- May 2, 2022
Related:
- Macro - concatenated cells until if finds a blank cell
- Auto run macro when cell value changes - Guide
- Run macro when cell value changes by formula ✓ - Forum - Excel
- Execute Macro On Calculated Cell change - Forum - Excel
- Excel - Run Macro on Cell Change ✓ - Forum - Excel
- Excel macro highlight cell based on value ✓ - Forum - Programming
1 reply
TrowaD
Jan 15, 2013 at 10:56 AM
- Posts
- 2880
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- May 2, 2022
Jan 15, 2013 at 10:56 AM
Hi Pfmoney,
See if the folowing code works for you.
Sorry for the many variables, I just added nameless counters until the desired result showed up.
NOTE: I assumed that "Space" in your example means empty cell.
Best regards,
Trowa
See if the folowing code works for you.
Sub test() Dim lRow, fRow, a, b, x, y, z As Integer fRow = Range("A" & Rows.Count).End(xlUp).Row x = 0 z = -1 Do x = x + 1 lRow = Range("A" & x).End(xlDown).Row y = lRow - x + 1 a = y z = z + 1 Do z = z + 1 If Range("B" & x).Value <> vbNullString Then Range("B" & x).Value = Range("B" & x).Value & "&" Range("B" & x).Value = Range("B" & x).Value & Range("A" & z).Value a = a - 1 Loop Until a = 0 b = y + 1 x = x + b - 1 Loop Until x > fRow End Sub
Sorry for the many variables, I just added nameless counters until the desired result showed up.
NOTE: I assumed that "Space" in your example means empty cell.
Best regards,
Trowa