PDA

View Full Version : VBA in Excel


Cuc Tu
03-09-2010, 11:24 PM
I'm having a hangup:

I first assign the active cell address to a variables:

x = ActiveCell.Address(0, 0)
y = ActiveCell.Address(0, 0)

so in this case x = "A1" and y = "A10"

That part is all fine.


I have the problem when I try to select this range of cells:

Range(x:y).Select

or

Range(x,y).Select

These don't work. :confused:

Cuc Tu
03-09-2010, 11:43 PM
Finally, it's so easy too...

Range([x], [y]).Select

Paul Komski
03-10-2010, 12:05 AM
Ahhhh. Syntax.

;)

Cuc Tu
03-26-2010, 07:22 PM
Another puzzle.

I record a macro that copies cells, moved to another worksheet, and then selects cells and pastes.

It works in a module, but when I dump the code in a button macro on the sheet, it fails:

Run time error 1004
application defined or object defined error


Private Sub CommandButton2_Click()

Range("C11002:E11002").Select
Selection.Copy
Sheets("Sheet2").Select
Range("B11002:C11002").Select
ActiveSheet.Paste

End Sub




Basically, the macro updates an axis scale on a chart using the variables above in the earlier posts.

The macro works fine on each sheet, but I've found that I want a macro on the master sheet that will copy the value there, and update all the remaining sheets with the same value.

I'm also having a problem with calling a sub (the button macro) from either the module or workbook, the routine can;t be seen and I'm not sure what I need to do to make it visible. I tried making it Public Sub UpdateChart(), but no workie.