adding new rows in excel without breaking a vba macro that uses Range.Value

wberg82

New Member
Joined
Feb 19, 2016
Messages
38
How do I auto update a macro so that if I add rows on a sheet it updates the range the macro is pulling from? For example, in the following code, my info is pulling from row 9. If I add to rows somewhere above this, this information is on now on row 11. However, I now need the macro to pull from row 11. I don't want to have to do into VB and manually update every code as this would take me forever......

With Sheets("Hardware Load List").Range("C" & Rows.Count).End(xlUp).Offset(1)
.Offset(, 1).Resize(, 5).Value = Range("D9:H9").Value
.Offset(, 6).Value = Range("J11").Value
.Value = Range("B9").Value
End With
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

offthelip

Well-known Member
Joined
Dec 23, 2017
Messages
1,470
Office Version
  1. 2010
Platform
  1. Windows
Used a named range, and refer to the named range in VBA, the named range will move if you insert rows above.
To refer to a named range called test you address it:
Code:
Range("test")
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,109,436
Messages
5,528,758
Members
409,834
Latest member
vexceled

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top