stirlingmw1
Board Regular
- Joined
- Jun 17, 2016
- Messages
- 53
- Office Version
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
Morning all
I have a worksheet "To_Email" that could contain up to 50 rows and 26 columns of data. This data has the first three columns detailing items (A - Product ID, B - Category and C - Description (starting at row 1 No Headers)) the remaining columns are the qty's for these items that each shop is holding. I am trying to loop through this data and concatenate each row into 2 cells starting from A51 & B51 so that I can then email the contents of these cells as an email body. The format I am trying to use is
Column A will have data from A to C with " - " as separators and
Column B will have data from columns D to Z with each qty on a separate line
so A51 will look like
B51 will look like
I can loop through a single column but cannot figure out how to loop through everything and format. I am using a msgbox as output just so i can see whether my code was working.
Thanks
Steve
I have a worksheet "To_Email" that could contain up to 50 rows and 26 columns of data. This data has the first three columns detailing items (A - Product ID, B - Category and C - Description (starting at row 1 No Headers)) the remaining columns are the qty's for these items that each shop is holding. I am trying to loop through this data and concatenate each row into 2 cells starting from A51 & B51 so that I can then email the contents of these cells as an email body. The format I am trying to use is
Column A will have data from A to C with " - " as separators and
Column B will have data from columns D to Z with each qty on a separate line
so A51 will look like
1234 - Fruit - Apples |
B51 will look like
12 24 30 |
I can loop through a single column but cannot figure out how to loop through everything and format. I am using a msgbox as output just so i can see whether my code was working.
VBA Code:
Sub GenerateString()
For i = 1 To 26
Range("A" & i).Select
strString = strString & " " & Selection & vbCrLf
Next i
MsgBox strString
End Sub
Thanks
Steve