Hello,
I have data in multiple columns and rows in a spreadsheet. I want to start at cell A1, read the value, perform some functions then move to A2 and so on until all the data in that is read I then need to go to the next column so it would be cell B1.
Some sample data is below:
170A 150B 220C
111J 243G 235G
554M 123G 456G
123H 567J
564N
I can cycle through reading the data in a column easily enough using the code below but I can't work out how to make it move back to row 1 and then to the next column.
With Sheets("Sheet1")
i = TotCols
'This line counts the rows that have data in the column
'assumption is that the data will always land in the same column
LR = .Range("A" & Rows.Count).End(xlUp).Row
For Each cell In .Range("A1:A" & LR)
If cell.Value <> "" Then
'Sheets("Sheet2").Copy After:=Sheets(2)
Sheets.Add(After:=Sheets(Sheets.Count)).Name = cell
Range("B2") = cell
ActiveWorkbook.SaveCopyAs Filename:="C:\Temp\" & cell & Dt & ".xls"
End If
Next cell
'Cells(Selection.Row, Columns.Count).End(xlToLeft).Offset(, 1).Select
End With
Any help would be appreciated
I have data in multiple columns and rows in a spreadsheet. I want to start at cell A1, read the value, perform some functions then move to A2 and so on until all the data in that is read I then need to go to the next column so it would be cell B1.
Some sample data is below:
170A 150B 220C
111J 243G 235G
554M 123G 456G
123H 567J
564N
I can cycle through reading the data in a column easily enough using the code below but I can't work out how to make it move back to row 1 and then to the next column.
With Sheets("Sheet1")
i = TotCols
'This line counts the rows that have data in the column
'assumption is that the data will always land in the same column
LR = .Range("A" & Rows.Count).End(xlUp).Row
For Each cell In .Range("A1:A" & LR)
If cell.Value <> "" Then
'Sheets("Sheet2").Copy After:=Sheets(2)
Sheets.Add(After:=Sheets(Sheets.Count)).Name = cell
Range("B2") = cell
ActiveWorkbook.SaveCopyAs Filename:="C:\Temp\" & cell & Dt & ".xls"
End If
Next cell
'Cells(Selection.Row, Columns.Count).End(xlToLeft).Offset(, 1).Select
End With
Any help would be appreciated