Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Auto fill form with data from worksheet

Hi,

I've created a user form, for the first time ever. The form is simply a
series of text boxes for data input with a couple of command buttons. I can
fill the text boxes in and it writes the data to the correct columns on the
correct worksheet. Great, but its a long form and it takes a while to fill
out.

Some of the data is already present in another worksheet, So to save data
entry time, I wanted to add a text box to allow the user to enter a reference
number, then add a command button that when clicked will find the reference
entered, by searching column A of a worksheet. Then I want the form to
autofill some of the other text boxes on the form with the data on the
worksheet from columns in the same row as the entered reference. If the
reference does not exist I want it to say so!

Problem, I'm no good at this yet and whilst I can get my form to write to a
worksheet I cant get it to read from one and autofill my text boxes.

Assuming this is possible, can anybody help / give me some tips? Any help
would be very much appreciated.

Thanks

John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Auto fill form with data from worksheet

John,
Use something like this. The variable "MyRef" will assigned from
your textbox i.e. MyRef=Textbox6.value

You could call FillForm from the appropriate Userform macro
(Commandbutton-Click).

HTH go get you started.

Sub FillForm(MyRef As String)

Dim ws1 As Worksheet
Dim RefRng As Range

Set ws1 = Worksheets("Sheet1") ' <=== change as required

With ws1
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
Set RefRng = .Range("a2:a" & lastrow)
' Look for mYRef in RefRng i.e. column A
res = Application.Match(MyRef, RefRng, 0)
If IsError(res) Then
MsgBox MyRef & " not found."
Else
refrow = res + 1 ' Assumes data starts in row 2
' Sample for assigning data to textbox from cell
Userform1.Textbox1.Value = Cells(refrow, 3) ' <===puts data form
Column C in textbox1
' add your code
End If
End With

End Sub

"mg_sv_r" wrote:

Hi,

I've created a user form, for the first time ever. The form is simply a
series of text boxes for data input with a couple of command buttons. I can
fill the text boxes in and it writes the data to the correct columns on the
correct worksheet. Great, but its a long form and it takes a while to fill
out.

Some of the data is already present in another worksheet, So to save data
entry time, I wanted to add a text box to allow the user to enter a reference
number, then add a command button that when clicked will find the reference
entered, by searching column A of a worksheet. Then I want the form to
autofill some of the other text boxes on the form with the data on the
worksheet from columns in the same row as the entered reference. If the
reference does not exist I want it to say so!

Problem, I'm no good at this yet and whilst I can get my form to write to a
worksheet I cant get it to read from one and autofill my text boxes.

Assuming this is possible, can anybody help / give me some tips? Any help
would be very much appreciated.

Thanks

John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Auto fill form with data from worksheet

Thanks Toppers,

Much appreciated, thats a big help!

"Toppers" wrote:

John,
Use something like this. The variable "MyRef" will assigned from
your textbox i.e. MyRef=Textbox6.value

You could call FillForm from the appropriate Userform macro
(Commandbutton-Click).

HTH go get you started.

Sub FillForm(MyRef As String)

Dim ws1 As Worksheet
Dim RefRng As Range

Set ws1 = Worksheets("Sheet1") ' <=== change as required

With ws1
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
Set RefRng = .Range("a2:a" & lastrow)
' Look for mYRef in RefRng i.e. column A
res = Application.Match(MyRef, RefRng, 0)
If IsError(res) Then
MsgBox MyRef & " not found."
Else
refrow = res + 1 ' Assumes data starts in row 2
' Sample for assigning data to textbox from cell
Userform1.Textbox1.Value = Cells(refrow, 3) ' <===puts data form
Column C in textbox1
' add your code
End If
End With

End Sub

"mg_sv_r" wrote:

Hi,

I've created a user form, for the first time ever. The form is simply a
series of text boxes for data input with a couple of command buttons. I can
fill the text boxes in and it writes the data to the correct columns on the
correct worksheet. Great, but its a long form and it takes a while to fill
out.

Some of the data is already present in another worksheet, So to save data
entry time, I wanted to add a text box to allow the user to enter a reference
number, then add a command button that when clicked will find the reference
entered, by searching column A of a worksheet. Then I want the form to
autofill some of the other text boxes on the form with the data on the
worksheet from columns in the same row as the entered reference. If the
reference does not exist I want it to say so!

Problem, I'm no good at this yet and whilst I can get my form to write to a
worksheet I cant get it to read from one and autofill my text boxes.

Assuming this is possible, can anybody help / give me some tips? Any help
would be very much appreciated.

Thanks

John

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto fill form from a worksheet Lucybella Excel Discussion (Misc queries) 0 February 20th 10 07:11 PM
auto fill entered data from one worksheet to another Jane Griffel[_2_] Excel Discussion (Misc queries) 2 September 9th 09 09:44 PM
Auto fill for data from another worksheet Frustrated Accountant Excel Discussion (Misc queries) 3 April 1st 06 09:24 PM
How do I use existing data from a worksheet to auto fill a second mac Excel Programming 0 October 26th 05 10:15 PM
Auto fill text boxes in user form by inputting data in another Finny33 Excel Programming 1 September 13th 04 12:53 PM


All times are GMT +1. The time now is 09:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"