Paste Formulas in Based on Cell Value

dclardy

New Member
Joined
Jun 9, 2011
Messages
4
I am trying to automate a process that we run daily at work, and I am having some trouble pasting formulas based on a value in another column.

For Category A and B, I need to paste two separate formulas. Here is the code that I currently have. It works when I do the record macro function, but it does not work when run through VBA.

I choose row 21 because it is a fixed cell, and I can paste into it easily. I was then trying to fill down, and then I would replace the contents of row 21.

Code:
'Paste Category Formulas In Category A
    
    Range("HL21:HW21").Select
    Selection.Copy
    Windows("Things that make it work.xls").Activate
    Range("A10").Select
    ActiveSheet.Paste
    Windows("Wall Plan.xls").Activate
    Selection.AutoFilter Field:=239, Criteria1:="a"
    Range("HL3:HW3").Select
    Selection.Copy
    Range("HL21").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Range("HL21:HW21").Select
    Selection.FillDown
            
    'Paste Category Formulas In Category B
    
    Selection.AutoFilter Field:=239, Criteria1:="b"
    Range("HL4:HW4").Select
    Selection.Copy
    Range("HL21").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Range("HL21:HW21").Select
    Selection.FillDown
    Windows("Things that make it work.xls").Activate
    Range("A10:L10").Select
    Selection.Copy
    Windows("Wall Plan.xls").Activate
    Range("HL21").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
    'Calc Sheet

It does not appear to be filling the formulas down.

Any help would be great with this? I have scoured Google, and I have not found anything that helps.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Any other ideas on this? I am sure that it can be done.

I just need to be place a formula when a cell value is equal to "a" or "b".
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,513
Members
452,921
Latest member
BBQKING

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