Maybe I'm in the wrong place with my code?

rharri1972

Board Regular
Joined
Nov 12, 2021
Messages
132
Office Version
  1. 2019
Platform
  1. Windows
I have a listbox1 on userform Customer Activity Center.

Listbox1 is filled with many customers and is multicolumn. Single Select

I also have a command button at the bottom (Insert Order) of the same userform.

I can click on or highlight a customer in listbox 1.... click on the button... and I have had help with code that enables the referenced value in listbox1.listindex(0) ( or the Customer ID) be searched out in Column A of the activated worksheet "Customers" and the cell with the same value selected.

Here is the code for that:

Code:
Private Sub CommandButton2_Click() '<--------- INSERT ORDER BUTTON on Customer Activity Center user form

Dim R As Range
  Set R = Sheets("Customers").Columns("A").Find( _
    ListBox1.Value, LookIn:=xlValues, LookAt:=xlWhole)
  If R Is Nothing Then
    MsgBox "Not found"
  Else
    'Activate sheet of found cell
    R.Parent.Activate
    'Select the cell itself
    R.Select
    
UserForm3.Show  '<--------Customer Order Form
    
  End If
 
End Sub

My issue is this... I am trying to get the value from the active cell into textbox14 on userform3.

Since my button click ends with userform3.show
I have gone into userform3_Initialize()

and used code:
Code:
me.textbox14.text = activecell.value

Everything I've read says this should work but it doesn't . I have even put this code inside of the actual textbox14 code but still nothing. Still so new maybe i just don't know where to put the code or maybe i'm just way off base with my code. Any help ? Finding the cell to activate with the same value as listbox listindex(0) works great...it moves to each cell related to whatever customer. I just can't get the cells value to textbox14 on userform3.

Any help will be greatly appreciated!!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try this...
Insert a new module. Add one line to it: Public R as Range

In your commandbutton2_click event, remove the "Dim R as Range" statement. You should then not have to activate the sheet or select the cell to reference the now public R variable from the userform's initialize event.
 
Upvote 0
Try this...
Insert a new module. Add one line to it: Public R as Range

In your commandbutton2_click event, remove the "Dim R as Range" statement. You should then not have to activate the sheet or select the cell to reference the now public R variable from the userform's initialize event.
PJOAQUIN... Thank you for trying to help but that also did not help. I removed the dim r as range from Command button 2... i removed the "me.textbox14...... line from my userform_initlialize...
i added a module with Public R as Range and still nothing. I just can't figure it out.
 
Upvote 0
Try this...
Insert a new module. Add one line to it: Public R as Range

In your commandbutton2_click event, remove the "Dim R as Range" statement. You should then not have to activate the sheet or select the cell to reference the now public R variable from the userform's initialize event.
PJOAQUIN... any other thoughts on what may work? I thought if i got the cell to activate within the worksheet I would have an easy time calling it over to the textbox but i can't figure this out
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,945
Members
449,095
Latest member
nmaske

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