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.
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,915
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))
 

Watch MrExcel Video

Forum statistics

Threads
1,113,989
Messages
5,545,355
Members
410,679
Latest member
rolandbianco
Top