How to access a specific worksheet in vba?

Asdf0qwerty

New Member
Joined
Jul 28, 2010
Messages
19
WorksheetAccessProb.jpg



As of now, I've already enabled my add-in in the Add-In dialog box and started to test in a new Excel Workbook file if it would work. Sadly, my add-in still halts at the statement above resulting to a "#VALUE!" result into the Cell.

In my uploaded image, you can see that there's 2 VBA projects. The one above is my add-in. Now I tried to add-watch "Application.Workbooks". Yes it did see a workbook, but it was VBAProject (Book1), not the workbook of my add-in. So how will I be able to access the Workbook (particularly the unviewable worksheets) of my add-in? TIA.

Btw, the worksheets enclosed inside the red box are the ones I want to access.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
SImply

Code:
Workbooks("ADD-IN WHT CALCU V1.0.xlam").Worksheets("MONTHLY")

OR

ThisWorkbok.Worksheets("MONTHLY")
 

pirdop

Board Regular
Joined
Jul 27, 2010
Messages
72
just in addition to what has already been said

don't know what your code is like but you might need to 'Activate' the worksheet

in this case

Activate.Sheets("NAME")

depending on what you want to do it can work simply
Sheets("name") or
Sheets(index number)


for example in a new work book excel's default
sheets(1) will return sheet named Sheet1
which equivalent to
sheets("Sheet1")
 

Asdf0qwerty

New Member
Joined
Jul 28, 2010
Messages
19
@All : Thank you for everyones inputs! and GBY all

@xld: Thank you!!! :D This did the trick!! :D

@pirdop: Thanks for the additional info. To be honest I don't know if I still need to use it because xld's already worked for me to access values in worksheets that I needed. So, in what case/s in Excel VBA programming should I use "Activate.Sheets(<name>)" ? TIA :D
 

Watch MrExcel Video

Forum statistics

Threads
1,132,680
Messages
5,654,716
Members
418,149
Latest member
tjanok

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