VBA/Macro help (Coding)

MikeyZ

Well-known Member
Joined
Mar 14, 2002
Messages
553
Here's my code:

Sub SetInvFormats()
'
' SetInvFormats Macro
'
'
Application.Goto Reference:="R1C3"
Selection.Copy
Application.Goto Reference:="R10C3"
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.AutoFill Destination:=ActiveCell.Range("A1:A90000")
ActiveCell.Range("C10:C90000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.Goto Reference:="R9C3"
ActiveSheet.Range("$A$9:$O$90000").AutoFilter Field:=3, Criteria1:="#N/A"
ActiveCell.Offset(1, 0).Range("A1").Select
Application.Goto Reference:="R9C3"
ActiveSheet.Range("$A$9:$O$90000").AutoFilter Field:=3
ActiveCell.Offset(-2, 0).Range("A1").Select
End Sub


I only want to copy down the formula to the last empty space in column "C".
The last line number varies from day to day.
But when I set up my code I don't want to specify the range by numbers.
ie: $A$9:$O90000

How can I get around that.

Hope this makes sense.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I replaced
Selection.AutoFill Destination:=ActiveCell.Range("A1:A90000")
with
Selection.AutoFill Destination:=ActiveCell.Range("C10:C" & lastrow)
But that dumped on me.
 
Upvote 0
Hi,

You could test the following macro
Code:
Sub Macro1()
' Copies from Cell C1 down to the last cell in Column C
Dim lastr As Long
lastr = Cells(Application.Rows.Count, "C").End(xlUp).Row
ActiveSheet.Range("C1").Copy Destination:=Range("C2:C" & lastr)
End Sub

HTH
 
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,222
Members
448,877
Latest member
gb24

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