Final Frontier
New Member
- Joined
- Sep 16, 2014
- Messages
- 17
Hello,
I am making an attempt at using VBA for the first time and it is not going well. I tried searching for help but I was getting confused when I try to modify to my own data.
My goal is to copy data from the Customer Data tab and paste into the Revenue tab. I will need to copy a few columns on the Customer Data tab until the first blank cell and then paste values into the Revenue tab. I will also need Column C on the revenue tab to label using the customer name (example: if customer A is 50 rows, I want to list the customer name in the Column C cells for only those 50 rows). Then I need to repeat this using different cells in different columns on the Customer Data tab. In short, I am looking to copy customer data and stack in the Revenue tab.
The code for the first 2 customers is below. Most was created using the Record Macro function as an example for what I am trying to accomplish. Can someone help me with this or direct me to a good source?
Thank you!
I am making an attempt at using VBA for the first time and it is not going well. I tried searching for help but I was getting confused when I try to modify to my own data.
My goal is to copy data from the Customer Data tab and paste into the Revenue tab. I will need to copy a few columns on the Customer Data tab until the first blank cell and then paste values into the Revenue tab. I will also need Column C on the revenue tab to label using the customer name (example: if customer A is 50 rows, I want to list the customer name in the Column C cells for only those 50 rows). Then I need to repeat this using different cells in different columns on the Customer Data tab. In short, I am looking to copy customer data and stack in the Revenue tab.
The code for the first 2 customers is below. Most was created using the Record Macro function as an example for what I am trying to accomplish. Can someone help me with this or direct me to a good source?
Thank you!
Code:
'Clear Contents
With Sheets("Revenue")
.Rows(4 & ":" & .Rows.Count).Delete
End With
'Copy Customer A data from Customer Data tab to Revenue tab
Sheets("Revenue").Select
Range("F3").Select
Sheets("Customer Data").Select
Range("B9").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Revenue").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G3").Select
Sheets("Customer Data").Select
Range("H9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Revenue").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I3").Select
Sheets("Customer Data").Select
Range("E9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Revenue").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E3").Select
Application.CutCopyMode = False
'Paste "Customer A"
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
With Sheets("Revenue")
For i = 3 To lastRow
If Len(Trim(.Range("F3" & i).Value)) <> 0 Then _
.Range("E3" & i).Formula = "=Customer A"
Next i...
Copy Customer B data from Customer Data tab to Revenue tab
Range("E280").Select
Sheets("Customer Data").Select
Range("J7").Select
Sheets("Revenue").Select
Range("D4:D279").Select
Selection.ClearContents
Range("D3").Select
Selection.AutoFill Destination:=Range("D3:D279")
Range("D3:D279").Select
Range("E280").Select
Sheets("Customer Data").Select
Range("J7").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Revenue").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Paste "Customer B"
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
With Sheets("Revenue")
For i = 3 To lastRow
If Len(Trim(.Range("F3" & i).Value)) <> 0 Then _
.Range("E3" & i).Formula = "=Customer B
Next i...