Formula within replace statement?

crazyeyeschase

Board Regular
Joined
May 6, 2014
Messages
104
Office Version
  1. 365
Platform
  1. Windows
I may be looking to deep at his but essentially I am getting a value (Price) from a websites source code, cleaning that info up, and then need to convert the value into USD.

If need be I could simply create a new column for for aesthetics I would like all conversions to be on one page. I have the conversion rate on sheet6 B2

This code does not have any attempts at converting the price just simply inputs it.
VBA Code:
Sub LPwilliams()
    Dim IE As Object
    Dim Price As String
    Dim i As Long

    Set IE = CreateObject("internetexplorer.application")
    For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
        With IE
            .Navigate ("https://www.triumph-spares.co.uk/search?q=" & Cells(i, "A").Value)
            .Visible = False
        End With
    
        Do While IE.readystate <> 4: Wait 5: Loop
    
        DoEvents
        
        On Error Resume Next
        Price = IE.document.getElementsByClassName("price price-new")(0).innertext
        Cells(i, "C").Value = Price
        
        If Err.Number = 91 Then
            Cells(i, "C").Value = "N/A"
        End If
        
        Cells(i, "C").Replace What:="EX VAT", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        Cells(i, "C").Replace What:="£", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        
    Next
        
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Essentially I thought putting this at the end would work but it doesn't.

VBA Code:
Cells(i, "D").Value = Cells(i, "C").Value*Worksheets("sheet6").Range("B")
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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