Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Userform searching and update

Hi, I am quite inexperienced in VBA but none the less I have managed to
create a userform to load data from the various text and list boxes
into the next blank line on a worksheet.
What I am trying to do now is to search for a particular reference
number which is on the worksheet (there will be several thousand
entries)and then automatically display a second userform that loads the
currently entered data for the row containing the reference number into
the userform, the user will then add more data into an number of extra
text boxes and possibly amend the existing data, all the data will then
be loaded onto the correct row in the worksheet.
Getting the data from the userform into the worksheet I think I can
do(apart from one problem)the trouble that I'm currently having is
searching for the reference number and populating the 2nd userform,
associated with that is how do I make sure that the data is being
entered onto the correct row, i.e the row containing the reference
number. I have purchased a number of books but none seem to have the
answers to my questions.

Any assistance would be very gratfully received

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Userform searching and update

I made two userforms.

In a general module, I put this code:

Option Explicit
Public myRow As Long
Sub showUserForm1()
UserForm1.Show
End Sub

Behind the userform1, I put this code:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()

Dim FoundCell As Range
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

With wks
With .Range("a:a")
Set FoundCell = .Cells.Find(what:=Me.TextBox1.Value, _
after:=.Cells(.Cells.Count), _
lookat:=xlWhole, _
LookIn:=xlValues, _
searchdirection:=xlNext, _
MatchCase:=False, _
searchorder:=xlByRows)
End With

If FoundCell Is Nothing Then
MsgBox "Key wasn't found"
Exit Sub
End If

myRow = FoundCell.Row
Load UserForm2
UserForm2.TextBox1.Value = .Cells(myRow, "B").Value
'rest of stuff

Me.Hide

UserForm2.Show

Me.Show

End With

End Sub

Behind userform2, I put this code:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
With Worksheets("sheet1")
.Cells(myRow, "C").Value = Me.TextBox1.Value
'and more??
End With
Unload Me
End Sub



wrote:

Hi, I am quite inexperienced in VBA but none the less I have managed to
create a userform to load data from the various text and list boxes
into the next blank line on a worksheet.
What I am trying to do now is to search for a particular reference
number which is on the worksheet (there will be several thousand
entries)and then automatically display a second userform that loads the
currently entered data for the row containing the reference number into
the userform, the user will then add more data into an number of extra
text boxes and possibly amend the existing data, all the data will then
be loaded onto the correct row in the worksheet.
Getting the data from the userform into the worksheet I think I can
do(apart from one problem)the trouble that I'm currently having is
searching for the reference number and populating the 2nd userform,
associated with that is how do I make sure that the data is being
entered onto the correct row, i.e the row containing the reference
number. I have purchased a number of books but none seem to have the
answers to my questions.

Any assistance would be very gratfully received


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Userform searching and update

Thank you for the help, I'm looking forward to trying it out when I
have a bit of spare time

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
Cause userform to update? quartz[_2_] Excel Programming 5 January 19th 05 01:28 PM
Userform update Ken McLennan[_3_] Excel Programming 0 November 1st 04 10:07 AM
userform with date searching in worksheet excelnewbie166 Excel Programming 5 November 28th 03 09:58 PM
How can I update the userform? Phillips Excel Programming 1 November 21st 03 05:33 PM
UserForm Update on the Fly Nigel[_4_] Excel Programming 2 October 15th 03 06:23 PM


All times are GMT +1. The time now is 07:30 AM.

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

About Us

"It's about Microsoft Excel"