Macro to format selected cells

B

BeSmart

Hi al
I'm not very good at writing Macros (I cheat alot and manually record them, then make minor changes when needed)..

Here I don't know the codes to enter to replace specific selections..
I need to change "Range("Q20:BP20").Select" to specify cells in columns Q:BP for the current selected ro
I also need to change the last action to re-select original active.cell

If I wanted to copy that macro and change the range selection to be whatever the user has just selected (ie current.selection), how do I write that

Sub Macro1(

' Macro1 Macr
' Macro recorded 6/05/2004 by BeSmar

Range("Q20:BP20").Selec
Selection.NumberFormat = "0
Range("Q20").Selec
End Su

Also, where is the best website to go and learn (basic dummy version) about writing, reading and understanding Macro/VBA code, ie the language and actions etc.. (eg I found cpearson.com really helpful for excel formula information - especially the excel-help download, is there anything like that to explain Macros and the definition of codes?
(I don't have VBA help installed on my laptop and the install disc's are 4 hours drive away in the head office....

Sorry for the basic question. Any help greatly appreciated.
 
M

mudraker

one way


column q to bp cells formated without selecting



Sub Macro1()
Dim Row1 As Long
Dim numRows As Long

Rows("20:30").Select
Row1 = ActiveCell.Row
numRows = Selection.Rows.Count
Range("q" & Row1 & ":bp" _
& Row1 + numRows).NumberFormat = "0"
Range("Q" & Row1).Select
End Su
 
D

Don Guillett

You could use
range("q20:bp22,q25:q35").format
or
selection.format


--
Don Guillett
SalesAid Software
[email protected]
BeSmart said:
Hi all
I'm not very good at writing Macros (I cheat alot and manually record
them, then make minor changes when needed)...
Here I don't know the codes to enter to replace specific selections...
I need to change "Range("Q20:BP20").Select" to specify cells in
columns Q:BP for the current selected row
I also need to change the last action to re-select original active.cell.

If I wanted to copy that macro and change the range selection to be
whatever the user has just selected (ie current.selection), how do I write
that?
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 6/05/2004 by BeSmart
'
Range("Q20:BP20").Select
Selection.NumberFormat = "0"
Range("Q20").Select
End Sub

Also, where is the best website to go and learn (basic dummy version)
about writing, reading and understanding Macro/VBA code, ie the language and
actions etc.. (eg I found cpearson.com really helpful for excel formula
information - especially the excel-help download, is there anything like
that to explain Macros and the definition of codes?)
(I don't have VBA help installed on my laptop and the install disc's are 4
hours drive away in the head office....)
 
B

BeSmart

Thanks Guy
I don't want the macro to work on specified row numbers or a range
It needs to apply to the current row the user is working on (eg the current cell) and apply to the cells between Q:BP for that row
you advice is appreciated
BeSmar

----- Don Guillett wrote: ----

You could us
range("q20:bp22,q25:q35").forma
o
selection.forma


--
Don Guillet
SalesAid Softwar
[email protected]
BeSmart said:
Hi al
I'm not very good at writing Macros (I cheat alot and manually recor
them, then make minor changes when needed)..
I need to change "Range("Q20:BP20").Select" to specify cells i
columns Q:BP for the current selected ro
I also need to change the last action to re-select original active.cell
whatever the user has just selected (ie current.selection), how do I writ
that
' Macro1 Macr
' Macro recorded 6/05/2004 by BeSmar

Range("Q20:BP20").Selec
Selection.NumberFormat = "0
Range("Q20").Selec
End Su
about writing, reading and understanding Macro/VBA code, ie the language an
actions etc.. (eg I found cpearson.com really helpful for excel formul
information - especially the excel-help download, is there anything lik
that to explain Macros and the definition of codes?
(I don't have VBA help installed on my laptop and the install disc's are
hours drive away in the head office....
 
D

Don Guillett

try
range(cells(activecell.row,"q"),cells(activecell.row,"bp")).format as
desired

--
Don Guillett
SalesAid Software
[email protected]
BeSmart said:
Thanks Guys
I don't want the macro to work on specified row numbers or a range.
It needs to apply to the current row the user is working on (eg the
current cell) and apply to the cells between Q:BP for that row.
 
Top