Is any method to simplify this VBA codes?

minmark

New Member
Joined
Jul 18, 2016
Messages
44
123456....31
a
b
c
d
e
f
...
k

<tbody>
</tbody>

I would like to shorten the following vba codes. Any good suggestion?
Thanks.


ActiveCell.Offset(42, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-72]C,'01_Logbook'!R9C17:R1009C17,R75C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-73]C,'01_Logbook'!R9C17:R1009C17,R76C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-74]C,'01_Logbook'!R9C17:R1009C17,R77C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-75]C,'01_Logbook'!R9C17:R1009C17,R78C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-76]C,'01_Logbook'!R9C17:R1009C17,R79C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-77]C,'01_Logbook'!R9C17:R1009C17,R80C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-78]C,'01_Logbook'!R9C17:R1009C17,R81C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-79]C,'01_Logbook'!R9C17:R1009C17,R82C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-80]C,'01_Logbook'!R9C17:R1009C17,R83C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-81]C,'01_Logbook'!R9C17:R1009C17,R84C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-82]C,'01_Logbook'!R9C17:R1009C17,R85C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-83]C,'01_Logbook'!R9C17:R1009C17,R86C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-84]C,'01_Logbook'!R9C17:R1009C17,R87C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-85]C,'01_Logbook'!R9C17:R1009C17,R88C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault

ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=COUNTIFS('01_Logbook'!R9C2:R1009C2,R[-86]C,'01_Logbook'!R9C17:R1009C17,R89C1)"
Selection.AutoFill Destination:=ActiveCell.Range("A1:AE1"), Type:= _
xlFillDefault
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
tell us what you are trying to do and check 1 to 31 and a to k is all you meant to show us, please
 
Upvote 0

Forum statistics

Threads
1,216,217
Messages
6,129,567
Members
449,517
Latest member
Lsmich

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