HTML Userform to Specific Table

gitmeto

Board Regular
Joined
Nov 24, 2021
Messages
60
I am looking at creating a web page that contains a userform where the data captured by the userform is then saved to a specific table in Excel. I found some code online that almost gets me there but instead of a specific table, it places it on a sheet. I would like to specify the table that the data from the userform is saved to. I am thinking this is an easy modification.

Any and all assistance is greatly appreciated!

VBA Code:
    <! DOCTYPE html>  
    <Html>  
       <Head>  
          <script language="vbscript" type="text/vbscript">  
             Sub Sample ()  
              Dim iRow  
              Set objExcel = CreateObject ("Excel. Application")  
              Set objWorkbook = objExcel.Workbooks.Open ("C:\Users\Karthikeyan.K\Desktop\Book1.xlsx")  
              objExcel.Application.Visible = True  
              ObjWorkbook.Windows (1).Visible = True  
              Set XlSheet =objWorkbook.Sheets (1)  
              XlSheet.Activate  
              iRow = 1  
              With objExcel  
                  Do while .Cells (iRow, 1).value <> ""  
                      .Cells (iRow, 1).activate  
                      iRow = iRow + 1  
                  Loop  
                     .Cells (iRow, 1).value=Document.GetElementsByName ("fname") (0).Value  
                     .Cells (iRow, 2).value=Document.GetElementsByName ("lname") (0).Value  
                     .Cells (iRow, 3).value=Document.GetElementsByName ("Add1") (0).Value  
                     .Cells (iRow, 4).value=Document.GetElementsByName ("Add2") (0).Value  
                     Document.GetElementsByName ("fname") (0).Value=""  
                     Document.GetElementsByName ("lname") (0).Value=""  
                     Document.GetElementsByName ("Add1") (0).Value=""  
                     Document.GetElementsByName ("Add2") (0).Value=""  
                 End With  
                 ObjWorkbook. Save  
                 ObjWorkbook. Close  
                 Set objWorkbook = Nothing  
                 Set objExcel = Nothing  
             End Sub  
          </script>  
          <style type="text/css">  
             fieldset {  
                border: #00cc00 2px solid;  
                padding: 10px;  
                color: green;  
          </style>  
       <body  
    <form>  
       <fieldset>  
          <legend>Csharpcorner</legend>  
          <center>  
             <img src="C:\Users\Karthikeyan.K\Desktop\Add-Male-User.png" alt="Mountain View"><br>  
             First name:<br>   
             <input type="text" name="fname" Value=""><br>  
             Last name :< br>  
             <input type="text" name="lname" Value=""><br>  
             Address1 :< br>  
             <input type="text" name="Add1" Value=""><br>  
             Address2 :< br>  
             <input type="text" name="Add2" Value=""><br>  
             <br>  
             <input type="button" onclick="Sample()" value="Submit" /><br>  
          </center>  
       </fieldset>  
    </form>  
    </body>  
    </html>

Form Code Link
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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