Varying Range - how will this effect my code?

geordie_ben

Board Regular
Joined
Jul 27, 2009
Messages
122
Apologies in advance for the basic question. I was slowly becoming a whizz at VBA a decade ago, but I'm picking it back up and need a few pointers

I'm making a macro to take info from sheet to another, and then to fill forumula that I've entered into the sheet already (that'll be a separate question to see if I can get the macro to insert the formula for me

The start of my code is:
Code:
    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Nominal Products").Select
    Range("B2").Select
    ActiveSheet.Paste
    Range("A2").Select
    Application.CutCopyMode = False
    Selection.AutoFill Destination:=Range("A2:A196")
    Range("A2:A196").Select
The next time I run the macro there may be more or less entries on sheet one. As above my macro states the range as A2:A196 - will this cause me any issues?
 
Last edited by a moderator:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Afraid not today as posted on my phone when at work (so amazed that I didn't make any typos :biggrin:)
 
Last edited:
Upvote 0
What's confusing? was not by a computer and so only gave an answer to our last question in this post because I could answer the question by writing freehand without testing on my phone.

Can't do that with new threads.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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