create macro


Khalil Handal

How can I create a TWO seperate macros in a spreadsheet in Excel:
there are icons/pictures which have a macro attached to it. How do I attach
the macro?

macro 1:
to move to a different cell address like B158.

macro 2:
to print a certain range of cells. (say A158:G200)

Thank u in advance

JE McGimpsey

One way:

Put something like these in a regular code module:

Public Sub MoveMacro()
Application.GoTo .Range("B158"), Scroll:=True
End Sub

Public Sub PrintCertainRange()
With ActiveSheet
.PageSetup.PrintArea = "A158:G200"
.PrintOut Preview:=True
.PageSetup.PrintArea = ""
.DisplayPageBreaks = False
End With
End Sub

Right-click your pictures, choose Assign Macro, and assign each picture
one of the above.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question