vba form and entering data to worksheet.

kxlvba

New Member
Joined
Jun 11, 2006
Messages
43
I'm having a tough time sorting this issue. Probably is someone can help me, it would be great.
I have a userform on which I enter my data. However there is one field of date, here I've used Excel VBA calendar 8.0 and made the arrangements. Till here everything is fine.
Now, on one particular worksheet on a particular with the help of a formula I get a numeric value..1,2,3,4,5 and so on.
I have worksheets by same numbers like 1,2,3,4,5

Now, I'm trying to use the below mentioned line of code but it acts funny because before 1 worksheet there is INDEX sheet and as per the below code it takes INDEX as 1, then 1 as 2, i.e. one previous.

The faulty code is

Set ws = worksheets(worksheets("Data List").Cells(4,18).value)

Somehow if I get Set ws = worksheets("1") then I can feed data correctly into 1 worksheets.

How do I accomplish this, I feel probably " " within worksheets function which are not present are causing this issue,

I tried inputing " " but it gives 424 Object error.

Please Help. I need to do this by tomorrow.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,303
Office Version
  1. 365
Platform
  1. Windows
What's probably happening is that VBA is thinking you are referring to the worksheets by their index rather than their actual name.

Try this.
Code:
Set ws = Worksheets(CStr(Worksheets("Data List").Cells(4,18).Value))
 

Forum statistics

Threads
1,141,022
Messages
5,703,791
Members
421,316
Latest member
Cyril Beki

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