473,394 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Avoid using Select method with worksheets in VBA macro. Help please.

Hi all

The application: VBA macro in which various Excel worksheets get printed, depending on the user's print selection via radio buttons.

The problem: As part of the macro, the print range has to be set, and the number of pages in the printed report echoed to the user, both of which depend on the relevant worksheet selected for printing. My coding for this is:

Expand|Select|Wrap|Line Numbers
  1. Print_Range = "A8:I" & ActiveCell.SpecialCells(xlLastCell).Row
  2. dPages = ExecuteExcel4Macro("GET.DOCUMENT(50)")
where both Print_Range and dPages are declared variables, and both operate correctly. EXCEPT, that as the user selects successive sheets to print, neither the Print_Range nor the dPages variables change, unless for each radio button option, the relevant sheets("name").selected is included. That makes sense to me, but I don't really want the worksheets to be changing on the screen all the time as the user selects a different sheet to print. Is there a correct way to let the macro know which sheet to test for xlLastCell and ExecuteExcel4Macro() without that sheet displaying on the screen?

I hope I've explained this clearly. Thank you guys for bringing me along in VB.

Annie
Mar 17 '10 #1
1 3133
Hi, Is there no way to do this?

In my search I have come across the syntax:

Pages = ExecuteExcel4Macro("Get.document(50,""Sheet2"")")

for getting number of pages in Sheet2, even if Sheet2 is not active. But when I try this without Sheet 2 being active (.Activate or .Select), it returns an Error 2042, something about a "type mismatch". I don't know how to cure this, since no matter how I declare the Pages variable, I get the same error.

What am I doing wrong here? Thanks.

Annie
Mar 20 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
0
by: pk | last post by:
I'm using SgmlReader (found at http://www.gotdotnet.com/Community/UserSamples/Details.aspx ?SampleGuid=b90fddce-e60d-43f8-a5c4-c3bd760564bc)and I'm trying to make it iterate over (process)...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
9
by: John Brock | last post by:
I am trying to create a workbook where one of the worksheets contains an AutoFiltered table. It looks like it should be simple -- what I am doing is this: rng = ws.Range("MyTableRange")...
0
by: SirMikesALot | last post by:
I'm pretty good at Excel, but my skills in Visual Basic are very limited. I found script on-line that creates & opens a user form, allows you to select your worksheets, prints the selected...
7
by: Holger Fitschen | last post by:
Hi to all, I want to use the Excel solver in a VB.Net project. The macro Sub Makro1Solver() Application.Run "Solver.xla!Auto_Open" SolverReset Worksheets(1).Select...
2
by: matthewwhaley | last post by:
What is the best way to essentially use the charindex(find) function if the value is could be more than one variable (A or B or C) I can't seem to get an "or", "if" or "select if" to work ...
2
by: GS | last post by:
I have installed the ms PIA for ofc XP, and followed the article http://support.microsoft.com/kb/247412/ trying to paste into a worksheet However I got late binding not allowed errors .......
4
by: sadc1986 | last post by:
How does one introduce multiple worksheets in a excel using Xslt Transforms my code... Please suggest <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...
2
newnewbie
by: newnewbie | last post by:
I am learning VBA and need a little help with a macro that I am writing. I have a worksheet with data that I split into multiple worksheets based on criteria in one column. E.g. Column A has unique...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.