Userform Help Please

jay111

New Member
Joined
Nov 7, 2009
Messages
2
Hi All,

I am new to this forum so apologies.

I was wondering if anyone could offer me some assistance / point me in the right direction.

Basically I would like display certain data from a given row in a spreadsheet via a userform which can be opened via a command button and take the required information from the row the user is clicked.

I.e. if the user is in row 2 then the relevant information from that row will be displayed.

Any chance of some assistance ????

Many thanks in advance,

J
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,

I have been playing around with forms all day so have a few bits and pieces.

Say that the sheet containing all the data = sheet1.

Once I have a form wanting to display say "name", "age", "Height" how do I take the information from sheet1 and put in the relevant place on the form ???

Any help would be great.
 
Upvote 0
Hi Jay.

I'm posting this code with a disclaimer that i can't explain how it works. :) .. its from one of the many board members who helped me with my latest userform.

Hope you can adapt it.. or one of the others here (y) can assist if not . Chuf

Code:
Private Sub cmbEdit_Click()
Dim varMatch
Application.ScreenUpdating = False
With Sheets("ABC Recharge")
varMatch = Application.Match(Me.txtRil, .Range("F:F"), 0)
If IsError(varMatch) Then
   MsgBox "Ref ID not found"
Else
   Me.cboTeamr = .Cells(varMatch, "A").Value
   Me.txtMan = .Cells(varMatch, "B").Value
   Me.txtVac = .Cells(varMatch, "C").Value
   Me.txtPub = .Cells(varMatch, "D").Value
   Me.txtDat = Format(.Cells(varMatch, "E").Value, "dd/mm/yy")
   Me.txtRef = .Cells(varMatch, "F").Value
   Me.txtFin = .Cells(varMatch, "G").Value
   Me.txtCos = Format(.Cells(varMatch, "H").Value, "###0.00")
 End If
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi Jay,

Try this code if you find the match function won't work


Code:
Private Sub cmbEdit_Click()
Dim MyRow As Integer
Dim LastRow As Integer
Dim MySheet As String
  
Application.ScreenUpdating = False
 
MySheet = "ABC Recharge"
LastRow = 1000 ' will look for MyRow as far as row 1000
MyRef = Me.txtRil
 
' start to look in each cell in Column F for MyRow
For i = 1 To LastRow
If Sheets(MySheet).Range("F" & i).Value = MyRef Then
MyRow = i
Else
End If
If MyRow > 0 Then GoTo EndLoop
Next i
 
EndLoop:
 
'Check a match was found
If MyRow = 0 Then
MsgBox "Ref ID not found"
Exit Sub
Else
 
End If
 
Me.cboTeamr = Sheets("ABC Recharge").Cells(MyRow, 1).Value
Me.txtMan = .Cells(MyRow, 2).Value
Me.txtVac = .Cells(MyRow, 3).Value
Me.txtPub = .Cells(MyRow, 4).Value
Me.txtDat = Format(.Cells(MyRow, 5).Value, "dd/mm/yy")
Me.txtRef = .Cells(MyRow, 6).Value
Me.txtFin = .Cells(MyRow, 7).Value
Me.txtCos = Format(.Cells(MyRow, 8).Value, "###0.00")
 
 Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,064
Members
448,545
Latest member
kj9

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