MikeExcelNovice
New Member
- Joined
- Feb 6, 2018
- Messages
- 3
I use the below script at work to easily and quickly concatenate large amounts of data. We use this to create a common denominator for vlookups between reports. I want to see if I can make this report as automated as possible. The script reads as follows:
Sub combine_columns()
Dim store As Variant
Dim sku As Variant
Range("D1").Select 'Change as appropriate
For Each sku In Range("B1:B") 'Change as appropriate
For Each store In Range("A1:A") 'Change as appropriate
ActiveCell.Formula = store & sku
ActiveCell.Offset(1, 0).Select
Next
Next
Range("D1").Select
End Sub
All I have to do is paste my data into columns A and B. Once that is complete I go into VBA and update the range to read B1:B6 and A1:A155 for example. Once I run the macro the concatenation populates in column D. To save time I wrote a COUNT formula in G2 to know my total range for A and a COUNT formula in H2 to know my total range for column B. Is there anyway to insert these values into the macro so I don't have to manually type them in every time.
For example, if my range in column A is A1:A64, cell G2 will read A64 so I know to go into the macro and edit A1:A(blank) to A1:A64.
Thanks for any help!!!!!
Sub combine_columns()
Dim store As Variant
Dim sku As Variant
Range("D1").Select 'Change as appropriate
For Each sku In Range("B1:B") 'Change as appropriate
For Each store In Range("A1:A") 'Change as appropriate
ActiveCell.Formula = store & sku
ActiveCell.Offset(1, 0).Select
Next
Next
Range("D1").Select
End Sub
All I have to do is paste my data into columns A and B. Once that is complete I go into VBA and update the range to read B1:B6 and A1:A155 for example. Once I run the macro the concatenation populates in column D. To save time I wrote a COUNT formula in G2 to know my total range for A and a COUNT formula in H2 to know my total range for column B. Is there anyway to insert these values into the macro so I don't have to manually type them in every time.
For example, if my range in column A is A1:A64, cell G2 will read A64 so I know to go into the macro and edit A1:A(blank) to A1:A64.
Thanks for any help!!!!!