I need a Macro that will copy Worksheet (Estimate1) I have 3 columns of data in Estimate1 in BY, BZ and CA to copy to Worksheet (Cost) it is to start at C1 then offset (skip) to M1, then skip down to next row. But as you can see it is not working properly.
This is the code I have so far
[pre]
[/pre]
If you like these VB formatting tags please consider sponsoring the author in support
This is the code I have so far
[pre]
Code:
Dim SheetName As String
SheetName = "Estimate1"
SheetName = InputBox("enter the name of a sheet to use", "sheet name", SheetName)
Dim i As Long
Dim MyCol As Integer
Dim MyRow As Integer
ActiveSheet.Range("E1:W17").ClearContents
LR = Sheets(SheetName).Range("BY" & Rows.Count).End(xlUp).Row
MyCol = 3
MyRow = 1
For i = 13 To 66
If Sheets(SheetName).Range("BY" & i).Value <> "" Then
Sheets("Cost").Cells(MyRow, MyCol).Value = Sheets(SheetName).Range("BY" & i).Value
MyCol = 3
MyRow = MyRow + 1
End If
If MyRow = 18 Then
MsgBox "You have ran out of room. Some entries were not copied"
Exit For
End If
Next i
LR = Sheets(SheetName).Range("BZ" & Rows.Count).End(xlUp).Row
MyCol = 5
MyRow = 1
For i = 13 To 66
If Sheets(SheetName).Range("BY" & i).Value <> "" Then
Sheets("Cost").Cells(MyRow, MyCol).Value = Sheets(SheetName).Range("BZ" & i).Value
MyCol = 5
MyRow = MyRow + 1
End If
If MyRow = 18 Then
MsgBox "You have ran out of room. Some entries were not copied"
Exit For
End If
Next i
LR = Sheets(SheetName).Range("CA" & Rows.Count).End(xlUp).Row
MyCol = 7
MyRow = 1
For i = 13 To 66
If Sheets(SheetName).Range("BY" & i).Value <> "" Then
Sheets("Cost").Cells(MyRow, MyCol).Value = Sheets(SheetName).Range("CA" & i).Value
MyCol = 7
MyRow = MyRow + 1
End If
If MyRow = 18 Then
MsgBox "You have ran out of room. Some entries were not copied"
Exit For
End If
Next i
End Sub
If you like these VB formatting tags please consider sponsoring the author in support