Copy Formula to last active cell in A

bloodybrit90

Board Regular
Joined
Jul 18, 2011
Messages
111
Hi Guys,

Right now this is the VBA I have. Instead of copying the formula down to FG403 all the time, I need to copy it to the last active cell (cell with data) in column A.

Thanks for the help


Range("FG33").Select
ActiveCell.FormulaR1C1 = _
"=IF(OR(RC[-5]=""Yes"",RC[-2]=""Yes"",RC[-1]=""Yes""),""Yes"",""No"")"
Range("FG33").Select
Selection.AutoFill Destination:=Range("FG33:FG403")
Range("FG33:FG403").Select
Selection.Copy
Range("FG33").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try this:
Code:
Sub test()
Dim lR As Long
lR = Range("A" & Rows.Count).End(xlUp).Row
With Range("FG33", "FG" & lR)
    .FormulaR1C1 = _
    "=IF(OR(RC[-5]=""Yes"",RC[-2]=""Yes"",RC[-1]=""Yes""),""Yes"",""No"")"
    .Parent.Calculate
    .Copy
    .PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
End With
Application.CutCopyMode = False
End Sub
 
Upvote 0
Joe, When I use your code, I receive a message "Compile error, expected end sub". The following is everything in my VBA window. Sorry I am a noob to VBA.

Sub ForeclosureInfo()
'
' ForeclosureInfo Macro
' Paste formula to determin flreclosures, then copy paste value all foreclosures
'
' Keyboard Shortcut: Ctrl+Shift+F
'
End Sub
Sub Foreclosure()
'
' Foreclosure Macro
' find foreclosure info and paste value.
'
' Keyboard Shortcut: Ctrl+Shift+G
'
Sub test()
Dim lR As Long
lR = Range("A" & Rows.Count).End(xlUp).Row
With Range("FG33", "FG" & lR)
.FormulaR1C1 = _
"=IF(OR(RC[-5]=""Yes"",RC[-2]=""Yes"",RC[-1]=""Yes""),""Yes"",""No"")"
.Parent.Calculate
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
Application.CutCopyMode = False
End Sub




This then has a button in one of the worksheets.
 
Upvote 0
Joe, When I use your code, I receive a message "Compile error, expected end sub". The following is everything in my VBA window. Sorry I am a noob to VBA.

Sub ForeclosureInfo()
'
' ForeclosureInfo Macro
' Paste formula to determin flreclosures, then copy paste value all foreclosures
'
' Keyboard Shortcut: Ctrl+Shift+F
'
End Sub
Sub Foreclosure()
'
' Foreclosure Macro
' find foreclosure info and paste value.
'
' Keyboard Shortcut: Ctrl+Shift+G
'
Sub test()
Dim lR As Long
lR = Range("A" & Rows.Count).End(xlUp).Row
With Range("FG33", "FG" & lR)
.FormulaR1C1 = _
"=IF(OR(RC[-5]=""Yes"",RC[-2]=""Yes"",RC[-1]=""Yes""),""Yes"",""No"")"
.Parent.Calculate
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
Application.CutCopyMode = False
End Sub




This then has a button in one of the worksheets.
Assign the button to Sub test and get rid of the rest of what you posted. You can rename what I posted from test to Foreclosure before assigning the button.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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