[RESOLVED] automate the writing of text value into rows and columns that can vary
Hi
I have a workbook that I create from a macro running in another workbook. The macro copies columns to the new (inactive, I guess) workbook into specific columns. So column "A" from the workbook can go into column "D" on the new workbook. I basically control which column by reading that as a number from a cell.
The problem I have is that I want to fill in a text value in some other columns in the new workbook for each of the rows that are copied. So if I copied 100 rows to the new workbook into column D then I want column A to contain the text value 'Item' in rows 2 through to 102. The column is variable and the number of rows it needs to fill is also variable.
Any idea how I can automate the filling of the text value into rows and columns that can vary?
Many thanks
paul
Re: how can I automate the writing of text value into rows and columns that can vary
After you are done copying to new workbook, create a script to run that will loop thru starting at 2 and going to last row with data in it.
Sample for you:
'Code to get last row
last_row = Range("D65536").End(xlUp).Row
'For Loop, starts at Row 2, goes to last_row variable, set value of cell A"row" to Item
For i = 2 To last_row
Range("A" & i).Value = "Item"
Next i
Re: how can I automate the writing of text value into rows and columns that can vary
Many thanks for the hint. Code is now working perfectly.