VBA code help

siggy8

New Member
Joined
Nov 13, 2015
Messages
1
Hello,
I'm hoping someone can help me out with this code. I'm new to VBA and trying to figure it out. I got the code to work for the first cell to copy down column A but can't get it to do the same for the next column of data. Any help is greatly appreciated. Here is my code, I've highlighted the trouble area in red. Thank you!!!

Dim a As Integer
Dim we As Date


a = Sheets("history tab").Range("c" & Rows.Count).End(xlUp).Row + 1
b = Sheets("history tab").Range("a" & Rows.Count).End(xlUp).Row + 1
we = Sheets("history tab").Range("g" & Rows.Count).End(xlUp).Row + 1

ActiveSheet.Range("b6:f20").Copy
Sheets("History Tab").Range("b" & a).PasteSpecial xlPasteValues

ActiveSheet.Range("b2").Copy
Sheets("History Tab").Range("A" & b).PasteSpecial xlPasteValues
With Sheets("History Tab")
lastrow = .Range("c" & Rows.Count).End(xlUp).Row
Do
Set c = .Columns(1).Find("", after:=.[A3], LookIn:=xlValues)
If c Is Nothing Or c.Row > lastrow Then Exit Do
c.Value = c.Offset(-1).Value
Loop
End With

ActiveSheet.Range("d3").Copy
Sheets("History Tab").Range("g" & we).PasteSpecial xlPasteValues
With Sheets("History Tab")
lastrow = .Range("a" & Rows.Count).End(xlUp).Row
Do
Set d = .Columns(1).Find("", after:=.[g3], LookIn:=xlValues)
If d Is Nothing Or d.Row > lastrow Then Exit Do
d.Value = d.Offset(-2).Value
Loop
End With

ActiveSheet.Range("b6:e20").ClearContents
ActiveSheet.Range("b6").Select

Sheets("History List").PivotTables("HistoryList").RefreshTable


End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
.Columns(1). is Column A, try changing it to .Columns(7).
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,753
Members
449,094
Latest member
dsharae57

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