VBA - Range Location updating based on cell location

NickNZL

New Member
Joined
Nov 23, 2011
Messages
4
Hi All,
I'm looking to automate a document that we send out to our customers. Basically it used to be a word doc that contained a whole bunch of descriptions and instructions about out product. This document gets altered to suit for each job we complete which takes a lot of time. Using excel and VBA I'm trying to make the whole thing go a bit faster. Basically what I'm doing is I have an 'Input' sheet where all the options are present in a tree form and then you put a '1' next to it if its there. That '1' hides or unhides entire rows in the 'Content' sheet.

The way I've done this is to first off set the locations of both the '1' and the content that that 1 refers to. Like this:

'This line refers to the cell that gets a '1' in it:

Set headUpperSwivelLock = Sheets("Input").Range("J7")

'This line sets the location of the related content:

Set contHeadUpperSwivelLock = Sheets("Content").Rows("101")

this is then turned on and off by an IF statement that depends on the 1.


This working great but I'm concerned that later on I'm going to want to come in and add extra information in. That means that I would have to add extra rows into the middle of the content data. This is obviously going to screw up any references that are below where I have added rows as VBA isn't aware of what I've done.

Finally my question. Is it possible to have VBA locations linked to a sheet so that if you move data in that sheet the reference gets update? i.e. like it works in excel where if you cut and paste a cell the formulas relating to it will update with the new reference.


I'm trying to get around this by adding a whole bunch of spare empty rows throughout the doc that get hidden at the end of a script if they're empty. Not a very elegant solution though.

Thanks for any help!

Best,
Nick
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,214,411
Messages
6,119,360
Members
448,888
Latest member
Arle8907

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