Hi all, I'm trying so detect the existence of a column of data by checking to see if the first cell in all possible columns contains data. If so, I want to copy the data from all ranges found this way into a single master column in a separate sheet. Currently the code appears to loop, detect, and copy correctly. I'm having trouble getting it to recognize the first unused cell in the master column and copying newly found ranges there. Instead it pastes each newly found range on top of the old one in a2. Any help would be appreciated.
Sub securityList()
Dim W As Worksheet
Dim Rng As Range
Dim Cel As Range
Dim RwCount As Integer
RwCount = 1
For Each W In ThisWorkbook.Worksheets
If W.Index < 6 Then
Set Rng = W.Range("a1:io1")
For Each Cel In Rng
If IsEmpty(Cel) = False Then
Range(Cel, Cel.End(xlDown)).Copy
Sheets("list").Activate
'I'm sure this line is the culprit but I'm not seeing my error
ActiveSheet.Cells(RwCount, 1).PasteSpecial Paste:=xlPasteValues
' or this one...
RwCount = Sheets("list").Range("a1").End(xlDown).Rows.Count + 1
End If
Next Cel
End If
Next W
End Sub
Sub securityList()
Dim W As Worksheet
Dim Rng As Range
Dim Cel As Range
Dim RwCount As Integer
RwCount = 1
For Each W In ThisWorkbook.Worksheets
If W.Index < 6 Then
Set Rng = W.Range("a1:io1")
For Each Cel In Rng
If IsEmpty(Cel) = False Then
Range(Cel, Cel.End(xlDown)).Copy
Sheets("list").Activate
'I'm sure this line is the culprit but I'm not seeing my error
ActiveSheet.Cells(RwCount, 1).PasteSpecial Paste:=xlPasteValues
' or this one...
RwCount = Sheets("list").Range("a1").End(xlDown).Rows.Count + 1
End If
Next Cel
End If
Next W
End Sub