Help with autofill

polska2180

Active Member
Joined
Oct 1, 2004
Messages
384
Office Version
  1. 365
Hello,

below is a part of the code im using. I want this code to be flexible enough so that any range of data will work with it. Thus I want the autofill part to not be limited to N2:n1860. I may have data thats only N2:n100 or n2:n3000.


Selection.AutoFill Destination:=Range("N2:N1860")
Range("N2:N1860").Select
Range("O2").Select
Selection.AutoFill Destination:=Range("O2:O1860")
Range("O2:O1860").Select
Columns("O:O").Select
Selection.Style = "Percent"
Columns("N:N").Select
Selection.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
Columns("N:N").EntireColumn.AutoFit
Range("M:M,K:K,J:J,F:F").Select

What code would I use to popup the save as window at the end of my code?

Thanks for the help
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
How would you be determining the row to fill to?
 
Upvote 0
Well a report is run on monthly basis and it varies with the number of rows. I'm trying to write a script that would be used by various users throughout my company. I need to make this very simple for them to use as most of them don't know computer at all.
 
Upvote 0
So how would you determine the row to fill to?

Is it based on data in a particular column?
 
Upvote 0
Okay i got part of the way with this code which i didn't write but works on one column, i need it done on three columns

Dim DestinationRng, OriginalRng As Range

Dim end_row As Integer
end_row = Sheets("Sheet1").Range("a65536").End(xlUp).Row

Set DestinationRng = Sheets("Sheet1").Range("H2:H" & end_row)
Set OriginalRng = Range("H2")

OriginalRng.AutoFill Destination:=DestinationRng, Type:=xlFillDefault

I get a error: Duplicate declaration in current scope., when I use this code for all three columns.

Help with fixing the code so that it can be used for three columns where I would replace H with N and O.

Thanks for the help
 
Upvote 0
Hi ,
i have a problem autofilling my sheet with variable row data.

Did you got a solution?

Please let me know how to autofill the data.

This is my code



Code:
Sub Time_macro()
'
' Time_macro Macro
' Macro recorded 9/27/2006 by Herbst
'

'
    Range("C22").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=RC1+R16C2/86400"
    Range("C22").Select
    Selection.NumberFormat = "h:mm:ss.000 AM/PM"
    Range("C22").Select
    Selection.ClearContents
    ActiveCell.FormulaR1C1 = "=R16C2+RC1/86400"
    Range("C22").Select
    Selection.AutoFill Destination:=Range("C22:C521")
    Range("C22:C521").Select
End Sub

Regards
 
Upvote 0
polska2180

Can you post the code that's giving the error?

pooj_malh

Can you post your working code?

It might help polska2180 or other board members.
 
Upvote 0

Forum statistics

Threads
1,214,859
Messages
6,121,963
Members
449,059
Latest member
oculus

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