Copy Excel rows into web page

TsarMarkI

New Member
Joined
Aug 14, 2019
Messages
20
Good afternoon all,

I'm looking to build a macro that will allow me to paste the contents of Column A in Sheet1 into a web URL entry box. The issue is that this has proven to be a little tricky to set up, as navigating to the specific input field on the website requires logging in and entering additional data for this field to appear. As such, I'd like to have the user navigate on their own to that point on the webpage, then run the macro and have the macro refer to that navigated page (IE works fine).

I need all the data in column A to be pasted into this field, one row at a time. Between each row being pasted in, I also need to simulate pressing the "Enter" key in order to send the data (this takes less than 2 seconds to do, after which point the field is cleared on the web page and ready to accept another entry). I've been playing around with the below macro:

Sub MoveItems()


Dim objIE As InternetExplorer
Dim y As Integer


For y = 1 To 4000
If Left(Sheets("Sheet1").Range("A" & y).Value, 1) = "G" Then
Sheets("Sheet1").Range("A" & y).Copy
objIE.document.getElementById("txtSerial").Value = ActiveCell.Value
objIE.document.getElementById("txtSerial").Paste
Application.SendKeys "~"
Application.Wait (Now + TimeValue("0:00:4"))
Else
y = 4001
End If

Next y


End Sub

The name of the entry field on the web page looks as below:

<INPUT onchange=AddToCartonList(); tabIndex=6 id=txtSerial title="Please Enter Serial" class=marg-inp style="WIDTH: 180px" maxLength=30 jQuery18306157905514084456="13">

Any help would be greatly appreciated!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Completely untested, perhaps something along the lines of
VBA Code:
Sub MoveItems()
    Dim objIE As InternetExplorer
    Dim rng As Range, cel As Range, OneItemOnly As String

    'the sheet to be dealing with
    With Sheets("Sheet1")
        'the range to work with... all data in col A
        Set rng = .Range("A1", .Range("A" & .Rows.Count).End(xlUp))
        'work with the cells in the range one at a time
        For Each cel In rng
            'only if the cell if starts with "G"
            If Left(cel.Value, 1) = "G" Then
                'put what's in the cell into string variable
                OneItemOnly = cel.Value
                'write the variable to the website plus Enter/Carriage Return
                objIE.document.getElementById("txtSerial").Value = OneItemOnly & vbCr
                'wait 2 seconds
                Application.Wait (Now + TimeValue("00:00:02"))
            End If
        'move on to the next cell
        Next cel
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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