active cell wont populate text box on form

Rob Mann

Board Regular
Joined
Jan 10, 2011
Messages
63
Please could someone look at the code below and tell me why the text box "txtjobnum" wont populate with the active cell in my "COMPLAINTS" sheet. The green code below is in the userform and the red text below that is in module 3. Any ideas?



Private Sub cancel_Click()
Unload Me
End Sub


Private Sub continue_click()
ActiveWorkbook.Sheets("COMPLAINTS").Activate
ActiveCell.Offset(0, 7) = recontactdate.Value
ActiveCell.Offset(0, 8) = recollectionreqd.Value
ActiveCell.Offset(0, 9) = note.Value
Unload Me
End Sub


Private Sub UserForm_initialize()
Me.txtjobnum = ActiveCell.Value
recontactdate.Value = Format(Date, "dd/mm/yy")
With recollectionreqd
.AddItem "Yes"
.AddItem "No"
End With
note.Value = ""
End Sub


Sub Find_Last1()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter a job number")
ActiveWorkbook.Sheets("COMPLAINTS").Visible = True
If Trim(FindString) <> "" Then
With Sheets("COMPLAINTS").Range("C:C")
Set Rng = .Find(What:=FindString, _
After:=.Cells(1), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
ActiveWorkbook.Sheets("COMPLAINTS").Visible = False
ActiveWorkbook.Sheets("OPTIONS").Select
EditEntry.Show
Else
MsgBox "Nothing found"
End If
End With
End If

End Sub
 

Some videos you may like

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,701
Office Version
  1. 2016
Platform
  1. Windows
The useform is activated but you haven't stated which sheet or cell it is to activate to?

if it had

sheets("The Name").Activate.Range("Cell ID").Activate

Then it would work. Change the sheet name and cell ID to the ones you want to work with

Private Sub UserForm_initialize()
sheets("The Name").Activate.Range("Cell ID").Activate
Me.txtjobnum = ActiveCell.Value
 

Weaver

Well-known Member
Joined
Sep 10, 2008
Messages
5,196
I created a test form using more or less the code you have and it worked fine, without having to explicitly reference the sheet and the cell (I think doing this defeats the object in any case)

Are there any other objects, like shapes or charts on the sheet that you might have selected when you open the form?
 

Watch MrExcel Video

Forum statistics

Threads
1,123,323
Messages
5,600,954
Members
414,417
Latest member
Nobu

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
Top