Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Formatting a Range

I'd like to copy the format/attributes of cell A2
to cells A3- end of sheet. Leaving A1 untouched.

Is this possible ?

Thanks - Kirk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Formatting a Range

Select A2
Click the format icon (a paintbrush in the Format toolbar)
Select all target cells in one go
All done

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"kirkm" wrote in message
...
I'd like to copy the format/attributes of cell A2
to cells A3- end of sheet. Leaving A1 untouched.

Is this possible ?

Thanks - Kirk



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Formatting a Range

Hi Kirk,

Assuming that VBA is required, try something like:

'==========
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim iLastRow As Long

Set WB = Workbooks("MyBook=.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE

With SH
iLastRow = LastRow(SH, .Columns("A:A"))
Set Rng = .Range("A3:A" & iLastRow)
.Range("A2").Copy
Rng.PasteSpecial Paste:=xlPasteFormats
End With
Application.CutCopyMode = False

End Sub
'<<=============


---
Regards,
Norman


"kirkm" wrote in message
...
I'd like to copy the format/attributes of cell A2
to cells A3- end of sheet. Leaving A1 untouched.

Is this possible ?

Thanks - Kirk



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Formatting a Range

Hi Kirk,

To avoid possible confusion,

Set WB = Workbooks("MyBook=.xls") '<<==== CHANGE


contains a typo and was intended as:

Set WB = Workbooks("MyBook.xls") '<<==== CHANGE

However, unless you have a requirement for a
VBA solution, use Bob's suggestion, instead


---
Regards,
Norman


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Formatting a Range

Thanks very much to both.

I'd try Bobs method but couldn't see how to select
row 2 to 29000 in one go.

Norman, I have an error in line

iLastRow = LastRow(SH, .Columns("A:A"))

Sub or Function not defined referencing "LastRow"

Also, as there's several colums to do this to, can I substitute
another column letter wherever you have "A" ?

Thanks - Kirk


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Formatting a Range

Hi Kirk

My apologies, I forgot to include the function,

Try:

'==========
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim iLastRow As Long

Set WB = Workbooks("MyBook=.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE

With SH
iLastRow = LastRow(SH, .Columns("A:A"))
Set Rng = .Range("A3:A" & iLastRow)
.Range("A2").Copy
Rng.PasteSpecial Paste:=xlPasteFormats
End With
Application.CutCopyMode = False
End Sub

'---------------
Function LastRow(SH As Worksheet, _
Optional Rng As Range)
If Rng Is Nothing Then
Set Rng = SH.Cells
End If

On Error Resume Next
LastRow = Rng.Find(What:="*", _
After:=Rng.Cells(1), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function
'<<=============

To rapidly select rows 2:29000, try typing:

2:2900
in the name box (above cell A1)



---
Regards,
Norman


"kirkm" wrote in message
...
Thanks very much to both.

I'd try Bobs method but couldn't see how to select
row 2 to 29000 in one go.

Norman, I have an error in line

iLastRow = LastRow(SH, .Columns("A:A"))

Sub or Function not defined referencing "LastRow"

Also, as there's several colums to do this to, can I substitute
another column letter wherever you have "A" ?

Thanks - Kirk



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Formatting a Range

Hi Kirk,

Also, as there's several colums to do this to, can I substitute
another column letter wherever you have "A" ?


Try changing:

iLastRow = LastRow(SH, .Columns("A:D))
Set Rng = .Range("A3:A" & iLastRow)


to (say):

iLastRow = LastRow(SH, .Columns("A:D"))
Set Rng = .Range("A3:D" & iLastRow)



Regards,
Norman


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Formatting a Range

Just hold-down the mouse key whilst selecting the row headings.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"kirkm" wrote in message
...
Thanks very much to both.

I'd try Bobs method but couldn't see how to select
row 2 to 29000 in one go.

Norman, I have an error in line

iLastRow = LastRow(SH, .Columns("A:A"))

Sub or Function not defined referencing "LastRow"

Also, as there's several colums to do this to, can I substitute
another column letter wherever you have "A" ?

Thanks - Kirk



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditionally Formatting a Range Anita Excel Worksheet Functions 1 February 8th 10 05:46 PM
Conditional Formatting with range Keyrookie Excel Worksheet Functions 2 December 3rd 09 02:20 PM
conditional formatting using a range Marc's NYK Excel Discussion (Misc queries) 1 August 14th 09 04:00 PM
Formatting range in concatanate Nigel Excel Discussion (Misc queries) 3 April 28th 05 12:02 PM
HOW TO USE CONDITIONAL FORMATTING FROM ONE RANGE TO ANOTHER RANGE PeggyP Excel Worksheet Functions 2 November 4th 04 07:29 PM


All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"