Adjusting Formulas with VBA

Neltu

New Member
Joined
Jan 28, 2009
Messages
25
Hello,

Currently i have a macro that copies data to a sheet based on conditions selected on a user form, after the user hits the second command button to view the new sheet, the Macro will paste a specific range that contains formulas below the last data.

The Formulas on the previous sheets were as follows:
=COUNTIF(B10:B124,"N/A")+1
=COUNTIF(B10:B124,"")
=COUNTIF(B10:B124,"*")

These tie into a tracking box that contains the following Formulas that check the range for a specific validation range below.
=COUNTIF(F10:F124,"PASS") and 4 more formulas like this one which look for specific validation answers from a drop down. Validation options are PASS, Fail, N/A. With one formula tracking blank validation cells as well

The problem i have is that they want the final sheet's first column to be deleted for the final outcome, but they still want the formulas to track any changes by the validation. (which of course throws it all off since B column is now A column and makes everything #REF)

Is there a way to adjust the formulas through the macro? Or would i have to manually adjust the formulas each time ? Would it be possible for the macro to update the formulas if the range of rows its looking at is not fixed, but all the columns are (after the initial delete of course)

This is the code i am using to modify the last sheet once the initial macro has been completed, this pastes the range with the formulas, and then deletes Column A.

Code:
Private Sub CommandButton2_Click()                                                              ' Done Button
 
   Sheet7.Range("TRACKER").Copy 'This will copy the needed range based on a defined name
   Sheets("Checklist").Activate
   ActiveCell.Offset(1).PasteSpecial 'This will put the named range where it needs to go
   Range("A4").Activate
   ActiveCell.EntireColumn.Delete
 
   Unload Me                                                                                    ' Closes the UserForm, but not the Excel Sheet.
End Sub

I tried just pasting special without deleting the column but it also just returned #REF in all those columns

Thanks in advance for any help you can provide me.:biggrin:
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,215,067
Messages
6,122,949
Members
449,095
Latest member
nmaske

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