VBA macro help

ariel20029

Board Regular
Joined
Jun 20, 2013
Messages
97
Hi, I have a workbook with 4 spreadsheets- Finance1, FixedFee,T&M,Basic.
I need to copy columns A&B from Finance1 from to the supporting spreadsheets based on the Type in column C ( FixedFee,T&M,Basic)- fixed fee would be copied on FixedFee tab,T&M on the T&M tab and Basic on basic tab.
I found this code, but I don't know how to do this.

One other wrinkle the data starts on row 6 on each sheet due to headers- I don't know if that matters.
Sub Macro1()
'

Dim LastRow As Integer, i As Integer, erow As Integer
LastRow = ActiveSheet.Range(“C” & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, 1) = Date And Cells(i, 2) = “FixedFee” Then
Range(Cells(i, 1), Cells(i, 7)).Select
Selection.Copy
Worksheets(“FixedFee”).Select
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
'
End Sub

Thanks for your help...::)
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try this....UNTESTED

Code:
Sub MM1()
Dim LastRow As Long, i As Long
LastRow = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
For i = 6 To LastRow
    Select Case Cells(i, 3)
        Case Is = "Fixed Fee"
         Range(Cells(i, 1), Cells(i, 7)).Copy Worksheets("FixedFee").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
        Case Is = "T&M"
         Range(Cells(i, 1), Cells(i, 7)).Copy Worksheets("T&M").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
        Case Is = "Basic"
         Range(Cells(i, 1), Cells(i, 7)).Copy Worksheets("Basic").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    End Select
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
 
Upvote 0
Try this....UNTESTED

Code:
Sub MM1()
Dim LastRow As Long, i As Long
LastRow = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
For i = 6 To LastRow
    Select Case Cells(i, 3)
        Case Is = "Fixed Fee"
         Range(Cells(i, 1), Cells(i, 7)).Copy Worksheets("FixedFee").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
        Case Is = "T&M"
         Range(Cells(i, 1), Cells(i, 7)).Copy Worksheets("T&M").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
        Case Is = "Basic"
         Range(Cells(i, 1), Cells(i, 7)).Copy Worksheets("Basic").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    End Select
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
Thank you I will give this a try!!!
Sharon
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top