programsam
Board Regular
- Joined
- Feb 10, 2016
- Messages
- 123
Hey gang,
Getting a run-time error with this code. Attempting to create separate worksheets and copy rows based on data in column "B" but it's getting hung up on this line.
When I look at values, all I get is tws = Nothing.
Here's the whole code.
Getting a run-time error with this code. Attempting to create separate worksheets and copy rows based on data in column "B" but it's getting hung up on this line.
Code:
Set tws = Sheets(cel.Value)
When I look at values, all I get is tws = Nothing.
Here's the whole code.
Code:
Sub splitData()
Dim sws As Worksheet
Dim tws As Worksheet
Dim cel As Range
Set sws = Sheets("Summary for Export")
For Each cel In sws.Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)
Set tws = Sheets(cel.Value)
cel.EntireRow.Copy tws.Range("A" & Rows.Count).End(xlUp).Offset(1)
Next cel
End Sub