Macro Problems

G

gillj

I am attempting to create a macro in Excel and am encountering problems.
The details are as follows:

The macro is for use in producing invoices, the template for which is set
up in Excel. The majority of my invoices use exactly the same wording, i.e.

Collect defective item and transport to our workshop
Strip item
Clean parts
Etc.

What has been happening is that when I run the macro it only prints the
first line unless I position the cursor in exactly the same cell as the
starting point when creating the macro. I actually need to be able to
commence the macro from any starting point.

I am not very familiary with Excel, but have discovered that my problem is
to do with relative references. However, I have tried recording a macro with
the
feature turned on, and then with it turned off, and the result is the same
each time.

A further problem which has nowoccurred is that when I press the ‘record
macro’ button, the stop recording toolbar which contains the relative
reference button no longer appears on the screen. What’s happened to it?
How do I get it back?

I would be grateful for any help on these issues as I have been struggling to
resolve them myself for some now.

gillj
 
M

mrice

You have hit upon the major limitation of recording macros, you have to
do exactly the same thing each time. By manually editing the macro you
have recorded or by writing one from first principles, you can overcome
this limitation. There are some examples on my download page which show
what a non-recorded macro might look like.

In you particular case, I would suggest that you look at the macro code
(ALT F11) and you add a new line to the beginning just after the Sub
Macro1 line.

Range("A1").Select

This will work assuming that A1 is the cell that has to be selected in
order for the macro to work properly.

The effect of this line is to mimic the action of selecting the cell.

I hope that this helps.
 

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

Top