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?
Sub Macro1()
Dim partNumber As Variant
Dim found As Range
Dim cCount As Long
Dim i As Long
partNumber = InputBox("Enter Part Number")
cCount = Range("A" & Rows.Count).End(xlUp).Row
Set found = Range("A1")
MsgBox cCount
For i = 1 To cCount
MsgBox i
Set found = Range("A:A").Find(what:=partNumber, after:=found, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not found Is Nothing Then
found.Hyperlinks.Add anchor:=found, Address:="http://shop.domain.com/part/" & partNumber, ScreenTip:=partNumber
End If
Next i
End Sub
Sub Macro1()
Dim partNumber As Variant
Dim myRng As Range
Dim c As Range
Dim cCount As Long
Dim i As Long
partNumber = InputBox("Enter Part Number")
cCount = ActiveSheet.UsedRange.Rows.Count
Set myRng = ActiveSheet.Range("A1:D" & cCount)
For Each c In myRng
If c.Value <> "" Then
c.Hyperlinks.Add anchor:=c, Address:="http://shop.domain.com/part/" & partNumber, ScreenTip:=partNumber
End If
Next c
End Sub
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("A1:D" & 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
Sub Macro1()
Dim partNumber As Variant - [COLOR="Red"]defines partnumber as the value entered when prompted by the code below[/COLOR]
Dim myRng As Range - [COLOR="red"]defines the variable used for the range[/COLOR]
Dim c As Range - [COLOR="red"]defines variable to be used for each instance?[/COLOR]
Dim cCount As Long - [COLOR="red"]counting each instance?[/COLOR]
Dim i As Long - [COLOR="red"]no idea :)[/COLOR]
partNumber = InputBox("Enter Part Number") -[COLOR="red"] creates call for variable defined by value entered in the inputbox[/COLOR]
cCount = ActiveSheet.UsedRange.Rows.Count - [COLOR="red"]defines the method of counting and limits it to only the active sheet [/COLOR]
Set myRng = ActiveSheet.Range("A1:D" & cCount) - [COLOR="red"]defines the range using only a letter for an individual colum or letter:anotherletter for multiple colums[/COLOR]
For Each c In myRng - [COLOR="red"]tells the process to continue while there is a count in the defined range[/COLOR]
If c.Value <> "" Then
c.Hyperlinks.Add anchor:=c, Address:="http://shop.domain.com/part/" & partNumber, ScreenTip:=partNumber - [COLOR="red"]creates the hyperlink[/COLOR]
End If
Next c - [COLOR="red"]continues until the previous statement is met[/COLOR]
End Sub - [COLOR="red"]ends the logic statement when the last count has been met[/COLOR]
Sub Macro1()
Dim myRng As Range Set the range we want to apply the hyperlinks to
Dim c As Range we need a single cell within the above
Dim cCount As Long last used row in the dataset
Dim i As Long For the for each loop
cCount = ActiveSheet.UsedRange.Rows.Count Sets the actual last row
Set myRng = ActiveSheet.Range("A1:D" & cCount) Sets the four columns we're interested in
For Each c In myRng Loop through the cells in that range
If c.Value <> "" Then
c.Hyperlinks.Add anchor:=c, Address:="http://shop.domain.com/part/" & c.Value, ScreenTip:=c.Value Sets up the hyperlink
End If
Next c Onto the next until we're all done
End Sub