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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,215,247
Messages
6,123,847
Members
449,129
Latest member
krishnamadison

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