Replace with formula after find?

ExcelJunior

New Member
Joined
Nov 23, 2011
Messages
18
I would like to know if it is possible to complete a "Find and Replace" but replace with a formula as opposed to a value?
 
I have been placed back on completing this task. I am getting a better understanding of the functions in your VB script. If I would like it to find any instances of a 5 digit part number anywhere in the sheet and complete the hyperlinking, what would need to be changed in the macro?
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I am receiving an error related to range while running the following macro:

Code:
Sub Macro1()
Dim myRng As Range
Dim c As Range
Dim cCount As Long
Dim i As Long
cCount = ActiveSheet.UsedRange.Rows.Count
Set myRng = ActiveSheet.Range("H1:I" & cCount)
    For Each c In myRng
    If c.Value <> "" Then
        c.Hyperlinks.Add anchor:=c, Address:="http://shop.domain.com/part/" & c.Value, ScreenTip:=c.Value
    End If
    Next c
End Sub

The part numbers that I would like to hyperlink are in columns H, I, L, and M. I would like to know how to better control the ActiveSheet.Range to only alter values found in specific columns. Is there a way to define this not as a range?
 
Upvote 0
Hi

Seems you cannot use .value if the cell is numeric, so just change this to .text instead. Also to loop through non-contagious ranges you can create an array and loop through that.

Code:
Sub Macro4()
Dim myRng As Range
Dim c As Range
Dim cCount As Long
Dim myArr As Variant
myArr = Array("H", "I", "L", "M")
Dim i As Long
cCount = ActiveSheet.UsedRange.Rows.Count + 1
For Each arr In myArr
Set myRng = ActiveSheet.Range(arr & "1:" & arr & cCount)
    For Each c In myRng
    If c.Value <> "" Then
        c.Hyperlinks.Add Cells(c.Row, c.Column), "http://www.domain.com/part/" & c.Text, c.Text
    End If
    Next c
Next arr
End Sub
 
Upvote 0
Excellent! Thank you again Dave! This has worked great for all of the spreadsheets I have done so far, wish me luck on the remainder!

- Excel Jr.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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