Rename Table using AfterUpdate on a ComboBox

richard_a

New Member
Joined
Jan 22, 2013
Messages
23
Hi Guys

I have a combobox on one sheet and a data table on another sheet. I'd like to use the combobox selection and AfterUpdate event to rename the data table. I've not been able to manage to get it working and wondered if someone could help?

To clarify, I only have 1 table on sheet2

The code below is what I have so far:

Code:
 [FONT='inherit']Private Sub CMB1_AfterUpdate()[/FONT]
[FONT='inherit'] With ThisWorkbook.Worksheets("Sheet2")

   [COLOR=#008000][I]'range G3 is the linked cell from the CMB1 and contains the first 3 letters (Left Function) of the text selected[/I][/COLOR]
.ListObjects(1).Name = Sheets("Sheet2").Range("G3").Value & "Table" [/FONT]

  [FONT='inherit']End With[/FONT]
  [FONT='inherit']End Sub[/FONT]


Many thanks for taking a look

Cheers,

Richard
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Richard

Is the code you posted not working?

If so, in what way?
 
Upvote 0
Hi Norie,

No the code doesn't work and when executed the table just remains with the same name as before. When I have the control on the same sheet as the table I want to rename then it works, but this isn't really an option for me as I want to keep the sheet containing the data out of the way (although not hidden)

Thanks,

Richard
 
Upvote 0
Is the code definitely being executed?
 
Upvote 0
Yes it's definitely being executed. It was coming up with an error message saying "out of range".

As it was working when the control was on the same sheet as the data table I just included a couple of extra lines of code to activate the sheet containing the data table prior to executing the renaming. Not sure why I didn't do this earlier, working fine now.

Thanks for replying to my post

Richard
 
Upvote 0
Richard

You shouldn't need to activate/select the sheet as long as you reference things properly.

Can you post your working code and/or details of which sheet(s) the table and combobox are located on?
 
Upvote 0

Forum statistics

Threads
1,221,525
Messages
6,160,327
Members
451,637
Latest member
hvp2262

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