VBA search column for formula then copy it over to another column

ceytl

Board Regular
Joined
Jun 6, 2009
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
I would like a VBA script to search G25:G800, when it finds any formula it will copy it and paste it one column over to the right on the same row.

All the formulas in the column are =SUM( formulas

Example =SUM(E48:E60)

Any help would be appreciated!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try this:
VBA Code:
Sub FindFormulaCells()
Dim Lr As Long, i As Long
Lr = Range("G" & Rows.Count).End(xlUp).Row
For i = 25 To Lr
If Range("G" & i).HasFormula() = True Then Range("H" & i).Formula = Range("G" & i).Formula
Next i
End Sub
 
Upvote 0
Try this:
VBA Code:
Sub FindFormulaCells()
Dim Lr As Long, i As Long
Lr = Range("G" & Rows.Count).End(xlUp).Row
For i = 25 To Lr
If Range("G" & i).HasFormula() = True Then Range("H" & i).Formula = Range("G" & i).Formula
Next i
End Sub

I thought when it copied over it would change the column reference in my formula, but it's the same.

I want to copy from this =SUM(E25:E45) to this =SUM(F25:F45)

Would you know how to do this?

Thanks!
 
Upvote 0
Try this:
VBA Code:
Sub FindFormulaCells()
Dim Lr As Long, i As Long
Lr = Range("G" & Rows.Count).End(xlUp).Row
For i = 25 To Lr
If Range("G" & i).HasFormula() = True Then Range("G" & i).AutoFill Destination:=Range("G" & i & ":H" & i)
Next i
End Sub
 
Upvote 0
Try this:
VBA Code:
Sub FindFormulaCells()
Dim Lr As Long, i As Long
Lr = Range("G" & Rows.Count).End(xlUp).Row
For i = 25 To Lr
If Range("G" & i).HasFormula() = True Then Range("G" & i).AutoFill Destination:=Range("G" & i & ":H" & i)
Next i
End Sub

Thank you!!!
 
Upvote 0

Forum statistics

Threads
1,215,807
Messages
6,127,005
Members
449,351
Latest member
Sylvine

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