How to access a specific worksheet in vba?

Asdf0qwerty

New Member
Joined
Jul 28, 2010
Messages
19



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.
 

Some videos you may like

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.

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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,495
Messages
5,511,663
Members
408,859
Latest member
willm57

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top