Various Excel VBA commands 2

Source: Internet
Author: User
Tags range

This example repeats the most recent user interface commands. This example must be placed on the first line of the macro.

Application.repeat

In the following example, the variable counter replaces the line number. This procedure loops through the cell range C1:C20, setting the number of all absolute values less than 0.01 to 0 (0).

Sub RoundToZero1()
For Counter = 1 To 20
Set curCell = Worksheets("Sheet1").Cells(Counter, 3)
If Abs(curCell.Value) 0 Then
'
Application.ActivePrinter = "\\zdserver2\HP LaserJet 5000 PCL 6

In Ne00: "' Specify printer

ActiveWindow.SelectedSheets.PrintOut Copies:=myprintnum,

Collate:=true ' Set printing information, where Copies:=myprint is the number of copies printed
Else
MsgBox "Please enter the number of copies to print"
End If
Activesheet.showalldata ' Show All
ActiveSheet.Protect password:=641112 ' Protect worksheet and set password
Sheets ("Cover page"). Select
application.screenupdating = True
End Sub

Sub Print balance ()
application.screenupdating = False
Sheets ("balance sheet"). Select
Call to reset All tables
ActiveSheet.Unprotect password:=641112 ' Undo Worksheet protection and remove password
Activewindow.scrollcolumn = 10
Selection.autofilter field:=1, criteria1:= ""
' The following 10 rows pop-up window input print information
Dim Myprintnum as Integer
Dim myprompt, MyTitle as String
Myprompt = "Please enter the number of copies to print"
MyTitle = "Print Selection range"
Myprintnum = Application.inputbox (Myprompt, MyTitle, 4,,,,, 1)
If Myprintnum 0 Then
' Application.ActivePrinter = ' \\zdserver2\HP LaserJet 5000 PCL 6 in

Ne00: "' Specifies the printer
ActiveWindow.SelectedSheets.PrintOut Copies:=myprintnum,

Collate:=true ' Set printing information, where Copies:=myprint is the number of copies printed
Else
MsgBox "Please enter the number of copies to print"
End If
Activesheet.showalldata ' Show All
ActiveSheet.Protect password:=641112 ' Protect worksheet and set password
Sheets ("Cover page"). Select
application.screenupdating = True
End Sub

Sub Backup ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.