PDA

View Full Version : 2 excel questions



Antony21
06-27-2007, 07:21 PM
Hi people!!! :hi:

I'm a new guy in this forum and I need some help with two things..., pleaseeee
In first place, in a Excel workbook, I need to run a macro in sheet 2 by click in a button on sheet 1. It seems to be very easy, but i've tried and so far I failed.
The second thing is, inside that's macro code, select a range of cells, copy them and paste them to another sheet on the same workbook. The copy range varies in accordance to the input of the macro and the paste range also varies. I tried to do something like that:

For t = 0 To Cells(2, 2)
Cells(4, t).Select
Cells(4, t).Copy_ Destination:=Sheets("Resultados").Range("A1").End(xlDown)
Next t

However, once again :(, an error occurs.

Can you guys help me?
Thanks in advance :thumb

lucas
06-27-2007, 08:16 PM
The copy range varies in accordance to the input of the macro
how is the copy range acquired?

johnske
06-27-2007, 11:53 PM
get rid of the underscore after copy :) also, you have for t = 0 To ... then Cells(4, t).Select - that will raise an error, use t = 1 To ...

Antony21
06-28-2007, 03:00 AM
how is the copy range acquired?
The copy range varies in terms of the number of columns that need to be copied to the other sheet. For example, in the input data for the macro, it has to be defined for how many "nodes" the calculations are executed. Therefore, the calculations are writed by the macro on the column AA to the column "X", where "X" depends of the number of "nodes" choosen before.

rbrhodes
06-29-2007, 05:45 PM
Hi antony21,

here's an example. One button is from the Control Toolbox toolbar the other is from the Forms toolbar. They are both found on the View/toolbars menu.

The Code is commented but it basically finds the last row of data first and then does the copy/paste.

Cheers,

dr

Antony21
06-29-2007, 07:00 PM
Hi antony21,

here's an example. One button is from the Control Toolbox toolbar the other is from the Forms toolbar. They are both found on the View/toolbars menu.

The Code is commented but it basically finds the last row of data first and then does the copy/paste.

Cheers,

dr

Thanks rbrhodes, you're the man! :D

Cheers