Hi guys,
Macro basic level user here.
I have created a macro but I need some help to get it a bit slicker as I have bolted it together like lego. I would also like the macro to repeat by looking at a list as opposed to me running it 200+ times.
Current code:
Sub NEXTINLIST()
Dim v As Variant
Windows("Ecc vs S4.xlsx").Activate
With Sheets("Reconciliation").Range("B4")
If .Value = "" Then
.Value = Sheets("Locations").Range("A2").Value
Else
v = Application.Match(.Value, Sheets("Locations").Range("A2:A263"), 0)
If IsNumeric(v) Then
.Value = Sheets("Locations").Range("A2:A263").Cells(v + 1, 1).Value
Else
.Value = ""
End If
End If
'
Windows("Ecc vs S4.xlsx").Activate
Range("G1:G4").Select
Selection.Copy
Windows("Reconciliation 2 Progress Tracker.xlsx").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Selection.Offset(1, 0).Select
'
End With
End Sub
Further info:
Macro basic level user here.
I have created a macro but I need some help to get it a bit slicker as I have bolted it together like lego. I would also like the macro to repeat by looking at a list as opposed to me running it 200+ times.
Current code:
Sub NEXTINLIST()
Dim v As Variant
Windows("Ecc vs S4.xlsx").Activate
With Sheets("Reconciliation").Range("B4")
If .Value = "" Then
.Value = Sheets("Locations").Range("A2").Value
Else
v = Application.Match(.Value, Sheets("Locations").Range("A2:A263"), 0)
If IsNumeric(v) Then
.Value = Sheets("Locations").Range("A2:A263").Cells(v + 1, 1).Value
Else
.Value = ""
End If
End If
'
Windows("Ecc vs S4.xlsx").Activate
Range("G1:G4").Select
Selection.Copy
Windows("Reconciliation 2 Progress Tracker.xlsx").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Selection.Offset(1, 0).Select
'
End With
End Sub
Further info:
- 'Locations' sheet has a list of 262 company's that I want the macro to look up to from C2:C63. I want the macro to repeat until it gets to the bottom of this list.
- After B4 in 'Reconciliation' has been selected the sheet needs to refresh to pull figures from a database. This is why I can't loop the macro at the moment, as the macro continues whilst the database is still refreshing.