Hello! I have an array of data, Column C is the ElementIDs of each box on a web form, and Column D is what I want to set the ElementID to.
I know how to do this for a single ElementID as follows:
But I have a case where each element ID is a row in a column, and each value is the corresponding cell to the right.
I have tried the following but am getting an error that "Element Value" is not defined.
Any help or advice is appreciated. Thank you!
I know how to do this for a single ElementID as follows:
VBA Code:
Dim IE As New SHDocVw.InternetExplorerMedium
Set IE = New SHDocVw.InternetExplorerMedium
Dim htmldoc As MSHTML.HTMLDocument
Set htmldoc = IE.Document
Dim element As MSHTML.IHTMLElement
Set element = htmldoc.getElementById("elementid")
element.Value = "value"
But I have a case where each element ID is a row in a column, and each value is the corresponding cell to the right.
I have tried the following but am getting an error that "Element Value" is not defined.
VBA Code:
Sub DataEntry()
'
'
'
Range("C2").Select
Range("C2").Formula2 = "formula that determines the name of the element ID that needs to be filled since they're all in order"
Range("D2").Select
Range("D2").Formula2 = "formula thats matches data from another sheet to go in each form box"
'loop through cells
Dim maxIDs As Long
maxIDs = Cells(Rows.Count, 1).End(xlUp).Row
Dim ElementIDArray As Range
Dim ElementValueArray As MSHTML.IHTMLElement
For Each ElementIDArray In Range("C1:C" & maxIDs).Cells
Set ElementValueArray = htmldoc.getElementById(ElementIDArray)
ElementValueArray.Value = ElementIDArray.Offset(0, 1)
Next ElementIDArray
End Sub
Last edited: