VBA Macro with variable parameters ?

StanSz

Board Regular
Joined
Sep 18, 2004
Messages
199
I have a workbook with data indicating various conditions having been met. I use a 1 in the cell to indicate that the conditions have been met, and the cell is left blank if the conditions have not been met.

There are some situations which result in Circular Errors.

I want to use a macro to copy the data from one column to another, so that I can avoid the circular error, by having one formula check the original column, while another formula checks the copy.

If the workbook calculates and gives results in Column T, for example, I want to copy over the results from Column T into Column E.

How can I write the macro to allow for an expanding worksheet, when rows are added. I can write the macro so that Cells T31 to T520 are copied into cells E31 to E520, but how do I allow for a new row being entered at row 31, which would push the old row 31 down into row 32, and push the old row 520 down to 521 ??

Also, is there a way to write the macro to allow for the possibility of Columns being added or deleated ?? Perhaps using some variation of a MATCH command (matching the column headings for one possibiliby) ??

I want to have the data which is currently in Column T always be copied over into what is currently Column E. Even if columns are added or deleated I want the old Column T to be copied to the old Column E.

Any suggestions ??

Am I correct in thinking that this macro should be placed as Worksheet_Calculate ??

Thanks

StanSz
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
What's the sheet look like? Post a sample for us if you can, please?

It depends on how the data is laid out, whether VBA can figure out where things go.

It could be a Calculate() event, or a Change() event. It depends on when you want the code to execute.
 
Upvote 0
I've got a sample to post, but I've never used Colo's HTML maker before for posting a ss.

I find that both version 2.42, and version 2.41 give me an error 91 message upon opening with macros enabled.

Is it me, or is there a problem there ??

StanSz
 
Upvote 0
OK, I figured it out:
Circular sample.adj3.xls
ABCDEFGHIJKLMNOPQRST
29Condition C checks for Condition T1 = Condition1 = Col TCondition T checks for Condition C1 = Condition
30C triggershas activatedT triggers
31AB1  
32 1QR1
33AB1 
34 1QR1
35AB1 QR
36  
37  
38  Q
39AB1 QR
40 1QR1
41AB1 
42  QR
43AB 
44  QR
45 1QR1
46AB1 
47A QR
Sheet1


Condition T checks for the prior activation of Condition C in Column C -- all's OK. Condition C needs to check for the prior activation of Condition T. I can't check Column T directly otherwise I get a Circular Reference. My idea was to copy (via a VBA macro) the results in Column T, into Column E, and then have the formula in Column C check not the data in Column T, but the data in Column E, (as per C31) which was copied via a Macro and is identical to what is in Column T.

StanSz
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

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