Load data from row into vba form

michiel

New Member
Joined
Jun 21, 2010
Messages
8
Hello,
I hope someone can help me.
I have created a form in excel vba that stores data in a row with a header.
Everything works fine, however I would like users to be able to edit a certain row, using the same form that they used for entering the data.
So, I would like to have a vba code that loads the data of a row from a selected cell into the form.

Before showing all the vba, is there maybe a very simple example to do this so I can addapt it in my code?

Thanks a lot in advance!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
this sample saves data from 10 textboxes called TextBox1 ..... TextBox10
into columns 1 to 10 on sheet1

Code:
Sub Sample()
    For col = 1 to 10
        Sheet1.cells(2,col) = Controls("TextBox" & col).value
    Next col
End Sub

' load from row number 34  (MyRow)

LoadData 34

Sub LoadData(MyRow as long)
    For col = 1 to 10
        Me.Controls("TextBox" & col).value = Sheet1.cells(MyRow,col)
    Next col
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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