Use A Macro To Print An Area, But Range Is Always Different
Hi everyone,
I have a macro that formats some data for me. I use this macro very often and I would like it each time that it is run to create the right print range, so that I can immediately print of my sheet if I need to. The problem I have is that although I always have the same number of columns at the same width but there are always more or less rows than the last time I printed. How do I get VBA to recognise this and select the print area that has data only. Also, there are some rows in my sheet that have no data...is this a problem (they are in between data though).
Cheers
Max
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Setting A Range Equal To That Of The Print Area
I have found code that will allow me to attach a certain range, on an excel sheet, into an outlook e-mail and then send it.
However, it requires you to select the range.
The range I want sent, happens to be the same range as the printable area.
Is there a way to just have the rangeToSend = printArea?
Range (Area) Help!!!
I am trying to create a Macro in Excel which will allow me to print a selected range (which will also be stated in the Macro).
For example,
Printing A3:A25,B3:B25, F3:F25,G3:G25,H3:H25
Even try to print this normally it prints 2 pages. One with A3:A25,B3:B25 and on the other F3:F25 etc.
Is there a way to combine these cells to one page, with each cell side by side?
Can anyone help? I am not sure how the CombinedRange or Union functions work.
Excel Macro, Subscript Out Of Range, But Its In Range?
i have a 2d array:
wds(1 to 24, 0 to 1)
the values in the array are set up correctly, but when i try to
output the values of the array to a cell i get the subscript out of
range error.
Below is the code that ive used to write to the cells, to test
that the array has the correct values the commented out
msgbox was used. (it returned the correct values)
except when i use the same code to assign the value to a cell's value i getthe error.
Code:
dim count1 as integer
count1 = 4
For counter2 = 1 To 24
'MsgBox (wds(counter2, 0))
Sheets("Doubles Results").Range("C" & count1) = wds(counter2, 0)
Sheets("Doubles Results").Range("E" & count1) = wds(counter2, 1)
count1 = count1 + 1
Next counter2
thanks for any replies
ps.
with other languages ive used to do simple calculations like
variable += 3 to add 3 to the variable
variable ++ to increment the variable
is there something similar to this in VB?
Excel Range Area For Mail Merge
Good morning folks.
I have a Excel spreadsheet with customer contact info.
I want to use this data in a mail merge from Word templates we have made up.
The manual process is to go to Insert --> Name --> Select Range Name --> Range.
What I want to do is when the spreadsheet filters are invoked, to change the spreadsheet range to reflect the new # of rows.
The code for setting this up is as follows:
ActiveWorkbook.Names.Add Name:="Print_Area", RefersToR1C1:= _
"='outstanding letters 05-07 thru '!R1C1:R2C12"
The problem is I want to put a variable in to replace the R1C1:R2C12. It would be a simple matter if it was in A1:B12 format.
DAVE
Area Selection In A Macro
I need help with selecting areas in a macro.
When I run a macro to search for a value in column "A" I need to then get the macro to go up one row and across to column "CA" I can do this by recording a macro & then pressing CTRL+SHIFT+HOME to select the area, but this puts the cell references in. My problem is that the length of the of the items in column "A" and subsequently the area of selection changes each time I run the search for different criteria. Is there a way as there used to be in Lotus 123 that you can enter a command that tells the cursor to go up 1 row and then select that cell and the ones between it and column "CA" then press CTRL+SHIFT+HOME to select the area involved?
Vba Macro In Unload Or Exit Area Of Excel
Hey guys. I want to write a VBA macro in Excel that basically checks if a certain cell has data in it. If so, the program can't close. Also, if possible, if that cell has data in it, the program can't save.
Possible?
Thanks
Print Area
In the VBA help it says that you can only set print areas in the format "$A$1:$C$5" using PageSetup.PrintArea. However all of my varaibles for definining the area of the sheet have numbers for the columns rather than letters, and if i do convert them to letters and try to conncatonate the variables together get an error saying "OPbject Required" if use set to create the concatonate printarea.
If i do not use set then i get an error saying "Object variable or With block variable not set"
Anyone got any advice as to where i am going wrong or if it is possible to to use column numbers rather than letters to create the print area?
Cheers,
nairnie
VBA Set Print Area???
Ok. I have a sheet where when the user chooses his/her name it advance filters to there detail. I also have a button that will print that detail. How can I get it to set the print area to how ever much detail is there because it differs from person to person. Let me know if you can grasp that. I know its kind of hard but let me know and I can try to explain it better. Thanks Guys and Girls
Print Range Of Pages, Find Length Of Document To Print
Hi, I am trying to accomplish two things.
1) I would like to find out how many pages would print out, IF I were to print. ie. Warn the user: "You have asked to print out 500 sheets at $4.50 a sheet."
2) I would like to choose a range of pages to print out, without that range set as the "default" the next time the print function is called. So, my current printing method below is not what I would like. (Unless there is a way to restore defaults?) It displays the normal print dialog, and remembers the last print range entered by the user.
I am displaying web pages on a form within the webbrowser control. Some are very long, so these features are important to me. How it is done is less important. Any advice is appreciated. Thanks!
Here is my very simple example code:
Code:
Option Explicit
'Load a web page
Private Sub Command1_Click()
WebBrowser1.Navigate ("http://www.vbworld.com/")
End Sub
'Brings up the print dialog box on button click.
Private Sub Command3_Click()
Dim eQuery As OLECMDF
eQuery = WebBrowser1.QueryStatusWB(OLECMDID_PRINT)
If Err.Number = 0 Then
If eQuery And OLECMDF_ENABLED Then
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER, "", ""
Else
End If
End If
End Sub
Private Sub cmdNavigate_Click()
Dim txtNavigate As String
WebBrowser1.Navigate txtNavigate
End Sub
Set Print Area In Excel
Hi all
Can someone help me, I am tring to set a selected range as a print area in excel via VB, so far I cannot find anything in the help or by doing the record button ...
thanks
dopper
Print Command In Vb6 To Print A Range In An Excel Worksheetsheet
Thank you for you assistance in populating an excel sheet from a vb6 user form textbox.
I am now struggling to print the excel sheet from vb6 command button.
I can print the worksheet but it is blank as I cannot work out how to set the print range.
Assistance would be appreciated as, after hours of trying, I am about ready to scream!!
Finding Last Cell For Print Area
the following piece of code is incorporated into an app that automatically scans through a series of folders for new data, each time that it finds it it places it into a txt document where excel picks it up.
the problem is that it only works for the first sheet then it returns an error (Runtime error '1004' method 'Cells' of object'_failed.
can anyone tell me what is wrong?
thanks in advance
peadar
Dim lRow As Integer, lCol As Integer, fRow As Integer, fCol As Integer
lCol = 14
fRow = 0
For i = 1 To lCol
lRow = Range(Cells(600, i), Cells(600, i)).End(xlUp).Row
If lRow > fRow Then
fRow = lRow
fCol = i
End If
Next i
lastcell = Range(Cells(fRow, lCol), Cells(fRow, lCol)).Address
stcell = "A1"
excel_app.ActiveSheet.PageSetup.PrintArea = stcell & ":" & lastcell
Setting Excel Print Area
Good morning people. I am creating a spreadsheet in which users will enter columns of data in an unknown number of rows (<1000). Also the totals will be on row 1000 and can be viewed in a split screen situation. My problem is, I want to set a print range (not for the whole 1000 rows) to include the occupied cells + row 1000. By default Excel will print only the occupied cells on a given page. I just want to utilize Excel's default "print area" and add the cells on line 1000 without printing a bunch of blank pages. Any suggestions?
Thank you, DAVE
Setting Print Area Using Variables In Excel
I am in need of some help on using variables in setting up in an
Excel Report I am working on.
I have different reports that output to Excel. I want to be able
to format these reports thru VBA, because when they are saved as
Excel from BusinessObjects, they are usually not very well
formatted. I want to be able to format these Excel Sheets
without having to go into each of them and format them manually.
I have been able with help from some of you to do that. Now
comes the last hurdle.
I want to be able to find the last cell that contains data (which
I have been able to). Then use that to set the print area,
before printing.
Below is the code that I use. It comes from a recorded macro
which I modified and it works. I now want to substitute my
variable r to replace the 4350. I have tried various methods and
none works.
Any ideas or suggestions will be greatly appreciated.
MsgBox ("First Empty Cell is at : " & r)
Range("A1:G4350").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$G$4350"
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.SmallScroll Down:=-21
Range("A1").Select
ActiveSheet.PageSetup.PrintArea = "$R$4350"
Range("A1:G4350").Select
' Range("A4262").Activate
'============================
ActiveWindow.SmallScroll Down:1
Rows("4351:29178").Select
Selection.Delete Shift:=xlUp
Selection.Delete Shift:=xlUp
Selection.Delete Shift:=xlUp
'Range("A4290:G4309").Select
' Selection.Delete Shift:=xlUp
Specifying A Range Within A Macro
The following code, which works fine, sets a destination range in a specified worksheet as Cell(rnum,1). So the row is rnum, which is defined earlier in the code, and the column is A:
With sourceRange
Set destrange = basebook.Worksheets(1).Cells(rnum,1)
End With
What I want to do is set the destination range as a range from Cell(rnum,1) to Cell(a,1)...where a is defined earlier in the code. Here's what I've tried, but it hasn't worked...Any suggestions? Feel free to PM me.
With Column("A")
With sourceRange
Set destrange = basebook.Worksheets(1).Cells(.Range(.Cells(rnum,1),.Cells(a,1)))
End With
End With
Dynamically Get The Range In Macro
Hi everyone,
My question is I need to use a macro to dynamically select all the non_blank cells (it woulld be like A1:D15 that always starts with A1 and ends with Dxx). The purpose is I will need to make a chart out of this range of data in macro.
I am very new to VBA. Can anyone help?
thank you very much
rita
Macro With A Variable Range
Selection.AutoFill Destination:=Range("F2:F104")
Range("F2:F104").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
I am a total newbie with VB, I know enough only to be able to read the code and decipher what it's doing. My issue is that I want the range -Range("F2:F104") - to start at F2 but fill in the formula for all rows. The worksheet has variable # of rows month to month. I could just put in a number larger than I'll ever have rows but it's time for me to learn a new trick. Thanks in advance for the help.
Cell Range Naming In Macro
im getting my self into all sorts of problems in Visual basic and excel could anyone help with this
Code:
Dim Rg As Range
Sheets("Classes").Select
Range("A2:A500,H2:H500").Select
Set Rg = Selection.SpecialCells(xlCellTypeConstants, 3)
Set Rg = Application.Union(Rg, Selection.SpecialCells(xlCellTypeFormulas, 3))
Rg.Select
'
End Sub
the code above selects a range of cells. What would be the code to which it gives these selected cell a name. (Cell range naming)
Selecting A Range While A Macro Is Running
I have a vba macro that transfers data between two spreadsheets.
The macro works; however, it would be better if the user could select the range to transfer while the macro was running.
Currently, before the macro is run, 1) the source sheet must be selected 2) the source range on the source sheet must be selected 3) the destination sheet must be selected.
Code:
FunctionTransferData(lRowDestination as Long, nCol as Integer, strSource as String) as Boolean
'lRowDest is the destination Row in the Destination Worksheet
'nCol is the column being transferred
'strSource is the path to the source workbook
Dim appXL As Excel.Application
Dim lRow as Long
Dim lRowDest as Long
Dim lRowFirst as Long
Dim lRowLast as Long
Dim objSourceWB As Excel.WorkBook
Dim objSourceWS As Excel.Worksheet
Dim objDestinationWS As Excel.Worksheet
Dim rngSource as Excel.Range
Set appXL = Excel.Application
'Debug.Print objWB.Name
Set objDestinationWS = appXL.ActiveSheet
Set objSourceWB = appXL.Workbooks(strSource)
Set objSourceWS = objSourceWB.Worksheets("Data")
objSourceWS.Activate
Set rngSource = appXL.Selection '<--------requires the selection to be made before the macro is run
lRowFirst = rngSource.Row
lRowLast = lRowFirst + rngSource.Rows.Count - 1
lRow Dest = lRowDestination
For lRow = lRowFirst to lRowLast
objDestinationWS.Cells(lRowDest, nCol) = objSourceWS.Cells(lRowDest, nCol)
lRowDest = lRowDest + 1
Next lRow
objDestinationWS.Activate
Set rngSource = Nothing
Set objSourceWS = Nothing
Set objSourceWB = Nothing
Set objDestinationWS = Nothing
Set AppXL = Nothing
End Function
Is there a way to select a range while a macro is running?
It would seem execution must be paused, the selection made and the execution continued.
Any help would be appreciated.
Macro Copy/Paste Range Question
I have a macro that will grab a certain range(in my case, "B3") from a series of separate spreadsheets, and insert this range into a given location in a new spreadsheet. However, instead of this insertion, or "paste" occuring only once, I would like for it to occur for a specified number of times (this # will be based on the number of rows in the range "data_range"). The only thing I'm having trouble with is getting this paste to occur multiple times. Please Advise. A snip-it of my current code is below.
Code:
With Application.FileSearch
NewSearch
.LookIn = "R:"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
Set basebook = ThisWorkbook
rnum = 1
For i = 1 To .FoundFiles.Count
Set mybook = Workbooks.Open(.FoundFiles(i))
Set sourceRange = mybook.Worksheets(1).Range("B3")
Set sourceRange2 = mybook.Worksheets(1).Range("data_range")
a = sourceRange2.Rows.Count
With sourceRange
Set destrange = basebook.Worksheets(1).Cells(rnum, 1)
End With
destrange.Value = Right(sourceRange.Value, 6)
mybook.Close
'rnum = i * a + 1
If rnum = 1 Then
rnum = i + a
Else
rnum = rnum + a
End If
Next i
Edit by 00100b:
Please use either the [vb] and [/vb] or [code] and [/code] tags when posting code snippets.
Thank you
Macro To Display A Named Range Of Cells
I have named a cell range on my worksheet but do not know the command in VB to display this cell range on a button click.
I understand how to make the button, it is mostly the VB functionality that I am confused with.
My named range of cells is "NecessaryCells" I want to create a macro that will filter out all cells other than the "NecessaryCells."
Any help would be very much appreciated, I assume this is a pretty simple question for most of you professionals to answer
Thanks in advance for any help you can give me.
-Mike
a.k.a The Ninja Coder
Using A Macro To Edit A Combo Box Format Range
could someone please help me with this as it has been driving me crazy for the past week.
I need to create a macro that updates the range a combo box uses for its input.
Say i have a combo box that has 10 pieces of data that it recieves from a table (e.g peoples names)
then someone adds a new name to the bottom of that list.
I need a macro to update the combo box with the new piece of data added.
please help.
Pivot Table / Chart Macro - Specified Range
Hi-
I am new to excel macros and VB and am not sure of the capabilities of vb.
I would like to write a macro that will pull data from an excel database and generate a table (from a custom template) and a series of graphs. My problem is that the range of the data will change each time these tables and graphs are generated. To be more specific, the data are sampling records that are entered into the excel database on a weekly or monthly basis. A table and a series of graphs need to be generated of the sampling records for a specified period of time, say, January 2003 through April 2003. I would like to write vb code that will produce a user interface that will ask the user for the specified dates and then will search the database for the specified dates and pull the data from that range in order to generate the tables and graphs. This interface will appear after the user selects a "report generating" button (which then starts the macro to create the tables and graphs). The dates will be in the database in the same form and will occupy a column. Is there any way to do this in excel vb? Do you know of any code to do this or any places I can look for examples?
Excel Macro - How To Modify Values In A Range All At Once
Hello, I'm using this to add and delete a space for every cell in a range (a column)
Code:
Range(Selection, Selection.End(xlDown)).Select
Selection.NumberFormat = "@"
For Each cell In Selection
cell.Value = " " & cell.Value
cell.Value = Right(cell.Value, Len(cell.Value) - 1)
Next
but the for-next cycle is too slow. (39000 rows)
so here is a faster way!
Code:
Range(Selection, Selection.End(xlDown)).Select 'this is the
'column to change
Selection.NumberFormat = "@" 'not there yet, we have to
'add and remove a space
'from each cell to achieve desired result
v = Selection
for i = 1 to ubound(v)
if isnumeric(v(i,1)) then
v(i,1) = "'" & v(i,1)
end if
next i
Selection.Value = v
thanks to Tom Ogilvy: http://groups.google.com/group/micr...5e9d918862bd670
thx
Pausing A Macro To Get A User Selected Range Of Cells
I need help with a certain code. I am working on a spreadsheet which isfiltered and I am trying to pause my macro so that the user can selectan area after it is filtered. Area selected is dynamic as amount oflines filtered will change each time. I found this code for selectingone cell but can't get it to select a range of cells. Below is thecode. Since I am new to VBA coding I am not sure what exactly it is Ineed to change. Any help is appreciated.
Dim UserRange As Range
Output = 565
Prompt = "Select a cell for the output."
Title = "Select a cell"
' Display the Input Box
On Error Resume Next
Set UserRange = Application.InputBox( _
Prompt:=Prompt, _
Title:=Title, _
Default:=ActiveCell.Address, _
Type:=8)
'Range selection
' Was the Input Box canceled?
If UserRange Is Nothing Then
MsgBox "Canceled."
Else
UserRange.Range("A1") = Output
Selection.Copy
End If
End Sub
Thanks
Delta
Macro W/ Embedded Excel Sheet: Error Script Out Of Range
Due to my worksheet's columns being aligned to where I don't have enough space to code in some new information I had to do the following:
MS Word: InsertObjectMS Excel WorksheetCopy it over to Excel and use Past SpecialExcel Worksheet Object
Next, after inputting the =sumif formulas, I created a Forms Button to have it execute the vb script. What needs to happen is for the formulas in the embedded excel sheet to update I have to open & close the embedded sheet. What I want is for the button to run that procedure automatically. When I execute that script it gives me the error "subscript out of range". The script is the following and in debug mode it highlights the 2nd row:
ActiveSheet.Shapes("Object 14").Select
Windows("Worksheet in Service Count Sheet").Visible = True
Selection.Verb Verb:=xlPrimary
ActiveWindow.Close
What can I do to resolve this? I have included a copy of the test sheet.
Thanks.
Troy
How To Set Print Range
Hello all
I have made print preview. But it was large that A4 size. I am notgetting that how to set print range and if it overflow then it goes tonext page.
And how to give next page for print preview and printer
Thanks
Amrit
Print A Range Of Dates
I'm trying to pull appointment dates from a database and just print them into a picture box. How do I search for the dates? I have two input boxes: one with the start date and one with the end date. Those dates, and the dates between them need to print into the picture box. I have no clue how to go about this. Here's what I have so far:
Private Sub mnuAppointments_Click() 'on a drop down menu
Dim strReportDate1 As String, strReportDate2 As String, foundFlag As Boolean
strReportDate1 = UCase(InputBox("Enter the Start Date (MM/DD/YY):"))
strReportDate2 = UCase(InputBox("Enter the End Date (MM/DD/YY:"))
If Len(strReportDate1) > 0 Then
datContacts.Recordset.MoveFirst
foundFlag = False
Do While (Not foundFlag) And (Not datContacts.Recordset.EOF)
If Trim(UCase(datContacts.Recordset.Fields("Next Appointment").Value)) = strReportDate1 Then
foundFlag = True
Else
datContacts.Recordset.MoveNext
End If
Loop
If Not foundFlag Then
MsgBox "Please try again"
datContacts.Recordset.MoveLast
End If
Else
MsgBox "Please enter a start date"
End If
Print A Worksheet Range From Vb 6.0
G'day All,
I have an application in vb 6.0 that collects data, saves it to a database then collects the data from the database and sends it to an excel worksheet from where it is printed.
My problem is that I need to print a specified range of cells (not the whole worksheet) for one of the reports.
Can anyone help me with the code for a cell range?
Code:
Dim comRpt As Command
Dim strErrorMsg As String
Set comRpt = Nothing
Set comRpt = New Command
Set rstReportDetails = New ADODB.Recordset
Set AppExcel = CreateObject("Excel.Application")
Set wBook = AppExcel.Workbooks.Open("S:Application-Res aApplication-all.xls")
Set wSheet = AppExcel.ActiveWorkbook.Worksheets("Credit")
wSheet.Cells(5, 3).Value = rstReportDetails("ApplicationNumber")
wSheet.Cells(5, 5).Value = rstReportDetails("LoanAmount")
wSheet.Cells(26, 2).Value = rstReportDetails("Description")
wSheet.Cells(27, 2).Value = rstReportDetails("MainPurpose")
wSheet.Cells(29, 1).Value = rstReportDetails("Conditions")
wSheet.Cells(33, 2).Value = rstReportDetails("CurrentlyWith")
wSheet.Cells(11, 4) = frmCreditCheck.txtGeneral.Text
Call wSheet.PrintOut
Any help would be appreciated. Thanks.
Dynamic Print Range
Hello to you
I need a subroutine that will look at a worksheet and identify the last cell that contains data and set the print area, up to and including that last cell. It must be renewable - i.e. it works every time new data is inputted onto the sheet.
Can anyone help me?????
Dynamic Print Range
Hello to you
I need a subroutine that will look at a worksheet and identify the last cell that contains data and set the print area up to and including that last cell. It must be renewable - i.e. it works every time new data is inputted onto the sheet.
Can anyone help me?????
Print Range In Excel
How can i set the print range in excel so that it will always print 1 page, if i use printArea it prints 2 pages instead of 1. Is it possible to always print to 1 page?
VB Code:
ActiveSheet.PageSetup.PrintArea = "$A$1:$R$55"
Clear Everything Outside Of Print Range
I am using the following sub routine in VB to clear all data in cells and columns outside a designated print range.
The problem is it only clears out up to Z. There are a few columns AA - AF that gets left. Why is this?
Cna you help?
-------------
Next shp
If sht.Name <> "Wellhead Data Sheet" Then
If sht.PageSetup.PrintArea <> "" Then
lRight = Right(sht.PageSetup.PrintArea, _
InStr(sht.PageSetup.PrintArea, ":"))
uLeft = Left(sht.PageSetup.PrintArea, _
InStr(sht.PageSetup.PrintArea, ":") - 1)
Set rngClear = sht.Range(lRight).Offset(0, 1)
rngClear.Select
Range(Selection, Selection.End(xlToRight)).EntireColumn.Delete
End If
End If
Range(uLeft).Select
sht.Protect ("ciw")
---------------
Print Block Of Range
I have this sheet with 5 block of range.
How to make a macro and assing to the button in this mode:
Set range from A to P (last cell in this case cont last cell from A) and print a copy
Set range from R to AG (last cell in this case cont last cell from R) and print a copy
ecc...
Peraphs is a init:
Option Explicit
Sub ShowUsedRange()
Dim ELENCO As Worksheet
Dim RIGA_MAX As Integer
Dim COLONNA_MAX As Integer
Dim I As Integer
Set ELENCO = Sheets("STAT_NEW")
RIGA_MAX = ELENCO.Cells(65536, 1).End(xlUp).Row
COLONNA_MAX = 16
With ELENCO
For I = 1 To 5
ActiveSheet.PageSetup.PrintArea = "$A$1:" & Cells(RIGA_MAX, COLONNA_MAX).Address
'HERE THE COMMAND TO PRINT OUT AREA
COLONNA_MAX = COLONNA_MAX + 16
Next I
End With
End Sub
Select Print Range
I have multiple charts on one sheet. When printing i want to select both the charts to be selected..either print on one page or more than one page
Can anyone tell me how to do it through VB ?
-ash
Print Data Between A Date Range
I have a data base with a long list of enteries which I would like to beable to use a macro to print enteries between to dates. If having it print is to hard how do I get to copy the enteries between the dates to a new worksheet
Appending A Range To A Print File
Yikes.
Haven't been here for a while...
Seem to be going down a lot of dead end threads with this one.
Need to print various ranges to either the active printer &/OR append to a file.
To the active printer,
myrange.printout is working great
to append to a file i just seem to get more lost.
- does not seem to be a vba utility?
- shell(whatever) is getting me lost... no file
concatenate function in DOS?
help greatly appreciated.
* * * *.. i keep hitting tab here and, duh, of course going to the "Submit NEw Thread" button. Hope i haven't inadvertently submitted any incompletes or extras
thanks again..
kak5157
Print Range In Excel From Vb Application
I have several vb user forms which populate an excel spreadsheet. I need to put a command button on a user form which will print out the excel sheet that has been populated. At no time will the user see the excel workbook.
I have managed to get as for as printing the sheet but the print-out is blank as I have been unable to work out how to tell the printer what the print range is.
I realise that this must be a very basic question but I would appreciate some help.
VBA Fill Formulas In Worksheets And Print Range
:huh: Hiya
Maybe you can help me with this one
Do you know what code I would need to fill down formulaes in subsequent worksheets depending on figures in a master sheet. Say Range("a3").Value
For example if the master sheet had 1 apple, 2 oranges and 3 tomatoes, how could it recognise the number of each and copy the last row of formulas according to the number?
I would then require the code to copy down the last row of formulas twice in the oranges worksheet and three times in the tomatoes. Basically it needs to be smart enough to formulas according to the number inserted in the first sheet.
Finally I need the macro to print say the last twenty rows of formulas in each worksheet ( a set print area which will encompass the new formulas that have been copied down).
It sounds easy but I think it is much more difficult
Here is the code I am using for the copy fill
Code:
Range("F24:G24").Select
Selection.Copy
Sheets("Macq True Index FI- FIFO").Select
Range("A130").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Data Sheet 106").Select
Range("C24:D24").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Macq True Index FI- FIFO").Select
Range("A131").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("C129:H129").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("C129:H131")
Range("C129:H131").Select
Range("H130").Select
Sheets("Macq True Index FI- FIFO").Select
Range("A130:A131").Select
Selection.Copy
Sheets("Macq True Index FI (Gains)").Select
Rows("135:135").Select
Application.CutCopyMode = False
Selection.Copy
Rows("136:137").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("B137").Select
Selection.ClearContents
Range("N136").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-12]=0,0,IF(RC[-7]-RC[-6]-RC[-5]=0,((RC[-12]-R[-1]C[-12])*RC[-4])," & _
"((RC[-7]*(RC[-12]-RC[-11]))+(RC[-6]*(RC[-11]-RC[-12]))+(RC[-5]*(RC[-10]-R[-1]C[-12])))))"
Range("N137").Select
ActiveWindow.LargeScroll ToRight:=-1
Range("B137").Select
ActiveCell.FormulaR1C1 = "1.001"
Range("B138").Select
End Sub
Common Dialog/PrintDialog API Print Range
All,
I have exhaustively searched this website as well as other to find how to activate the Current Page or the Pages radio options on either the commondialog control or the PrintDialog API. If anyone could point me in the right direction that would be helpful.
I have been setting the .Flags to cdlPDPageNums, in fact, I have tried all available flags in some combination. Maybe there is a trick to an And/or clause in the setting of the flag that I am just not getting correct.
Thanks in advance
VBA Excel: Combine Print Range On Same Page
Assign multiple print ranges within a single Excel Worksheet
Is this performed through a pagesetup function? Please get me started...thanks
Private Sub CommandButton1_Click()
Dim rCol As Range
Dim rCell1 As Range, rCell2 As Range
Dim Sht As Worksheet
'Set range variable to Selection
Set Sht = ActiveSheet
Set rCol = Sht.UsedRange.Columns(1)
'Insert page breaks
Sht.PageSetup.PrintArea =
Need Help In Print Macro
I have a macro which prints out an invoice. The data in the invoice is put in from another sheet using vlookup formulas. I want my macro to look at one of the cells to make sure it has data entered. At the moment if no data if entered it says "#N/A". How can i make my macro print my invoice out if the cell isn't "#N/A"?
I tried this but it didnt work.
Code:
Sub print2()
If Range("D13:H13").Value = 0 Then
MsgBox "No Account Number Selected. Please select an account number to print."
Sheets("Order").Select
Else
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
End Sub
In this one it has "0" because i tried doing account number. Which if no data is entered comes up as 0.
Print Macro
Using Excel what is the macro code to produce a print macro that prompts the user for the number of copies required and then prints that number of copies the user has requested.
Print Command Macro
Ok, I'm a total novice....
In excel, i want to assign a macro to a button on sheet one that will automatically print sheet 2. Can this be done and how??
Print Macro Issue
I am looking for assistance with print macros in excel 2003 running on XP...
The issue is that, when recording a macro for printing to a network printer, the printer definition will come up as
" Copy Room 5M on NE02:"
This will work temporarily, however, there appears to be a reassignment of the "NE02" on the actual machine - if I record the same print sequence even moments later, the code may look like this
" Copy Room 5M on NE00:"
Essentially, this negates the value of the original script making it impossible to designate a printer....
Any ideas???
Thanks
Word Print Macro
I want to be able to print from a different tray in MS Word 2000 using a macro but i haven't been able to do so and I decided to come here to see If I can get some answers. here's the link to where i previously posted, but I didn't get too many replies. Hopefully i will get more here.
THanks
http://techimo.com/forum/t34352.html
Macro: Close Word After Print
Is there a way I can close word automatically after a file prints?
here is the macro:
Code:
ActiveDocument.PrintOut
Application.Quit
with this it prompts and says if word exits the print will stop. is there an .isbusy command or something similar to that..so that i can have the application wait until printing completes and then exit?
thanks
-B
Automatically Print On Opening Macro
Hello
I am trying to build a macro to print automatically when the document is opened.
can anyone tell me how to do this?
I have tried creating a new macro in a template and put this code in:
<vbcode>
Sub pr()
'
' pr Macro
' Macro created 28/08/2003 by adavies
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub
</vbcode>
That is in a macro in the document.
When I open the document, it does not automatically print.
Can someone help?
|