Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Selecting portions of a column instead of the whole colum

Hello, XL 2003 and 2007.
Have the code listed below that selects an entire column and then colors and
formats it. My problem is that I don't need the entire column but only D4
down. D4 contains the beginning statement for my pivot table. The length of
the column will be variable and I'm not sure how to put the code in to take
it from D4 down to the last complete cell.

Can someone help with the code, and the coloring is supposed to be for the
range and not the entire column
Thanks
BOB R




ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
With Selection
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
End With
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Selection.Font.Bold = True
Selection.Font.Italic = True


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Selecting portions of a column instead of the whole colum

you don't really specify where your data starts. this should illustrate what's
actually happening, although there's a shorter way.
i assumed the active cell was in row 1. if you could be more specific instead of
using activecell, it would be better.

Sub test()
Dim lastrow As Long
lastrow = Cells(Rows.Count, ActiveCell.Offset(0, 1).Column).End(xlUp).Row
With Range(ActiveCell.Offset(0, 1).Address, Cells(lastrow,
ActiveCell.Offset(0, 1).Column).Address)
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 36
.Interior.Pattern = xlSolid
.Font.Bold = True
.Font.Italic = True
End With
End Sub


--


Gary


"BobR" wrote in message
...
Hello, XL 2003 and 2007.
Have the code listed below that selects an entire column and then colors and
formats it. My problem is that I don't need the entire column but only D4
down. D4 contains the beginning statement for my pivot table. The length of
the column will be variable and I'm not sure how to put the code in to take it
from D4 down to the last complete cell.

Can someone help with the code, and the coloring is supposed to be for the
range and not the entire column
Thanks
BOB R




ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
With Selection
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
End With
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Selection.Font.Bold = True
Selection.Font.Italic = True



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Selecting portions of a column instead of the whole colum

Thank you Gary, Sorry I'm sorta new at this and used a record macro to get
where I am.

The active cell will need to be set and it will be set at D4. So if I set
the active cell and then then it will go down to the xlUP and select that
range??? At this point I want it to placed the background color in these
cells.
Then it will color it and make the font bold italic.

Thanks again.
Bob
"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
you don't really specify where your data starts. this should illustrate
what's actually happening, although there's a shorter way.
i assumed the active cell was in row 1. if you could be more specific
instead of using activecell, it would be better.

Sub test()
Dim lastrow As Long
lastrow = Cells(Rows.Count, ActiveCell.Offset(0,
1).Column).End(xlUp).Row
With Range(ActiveCell.Offset(0, 1).Address, Cells(lastrow,
ActiveCell.Offset(0, 1).Column).Address)
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 36
.Interior.Pattern = xlSolid
.Font.Bold = True
.Font.Italic = True
End With
End Sub


--


Gary


"BobR" wrote in message
...
Hello, XL 2003 and 2007.
Have the code listed below that selects an entire column and then colors
and formats it. My problem is that I don't need the entire column but
only D4 down. D4 contains the beginning statement for my pivot table. The
length of the column will be variable and I'm not sure how to put the
code in to take it from D4 down to the last complete cell.

Can someone help with the code, and the coloring is supposed to be for
the range and not the entire column
Thanks
BOB R




ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
With Selection
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
End With
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Selection.Font.Bold = True
Selection.Font.Italic = True





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Selecting portions of a column instead of the whole colum

try this and see if it works, i don't know if you have any blank cells in the
range or not

Sub test()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
With Range("D4:D" & lastrow)
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 36
.Interior.Pattern = xlSolid
.Font.Bold = True
.Font.Italic = True
End With
End Sub


--


Gary


"BobR" wrote in message
...
Thank you Gary, Sorry I'm sorta new at this and used a record macro to get
where I am.

The active cell will need to be set and it will be set at D4. So if I set the
active cell and then then it will go down to the xlUP and select that range???
At this point I want it to placed the background color in these cells.
Then it will color it and make the font bold italic.

Thanks again.
Bob
"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
you don't really specify where your data starts. this should illustrate
what's actually happening, although there's a shorter way.
i assumed the active cell was in row 1. if you could be more specific instead
of using activecell, it would be better.

Sub test()
Dim lastrow As Long
lastrow = Cells(Rows.Count, ActiveCell.Offset(0,
1).Column).End(xlUp).Row
With Range(ActiveCell.Offset(0, 1).Address, Cells(lastrow,
ActiveCell.Offset(0, 1).Column).Address)
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 36
.Interior.Pattern = xlSolid
.Font.Bold = True
.Font.Italic = True
End With
End Sub


--


Gary


"BobR" wrote in message
...
Hello, XL 2003 and 2007.
Have the code listed below that selects an entire column and then colors and
formats it. My problem is that I don't need the entire column but only D4
down. D4 contains the beginning statement for my pivot table. The length of
the column will be variable and I'm not sure how to put the code in to take
it from D4 down to the last complete cell.

Can someone help with the code, and the coloring is supposed to be for the
range and not the entire column
Thanks
BOB R




ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
With Selection
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
End With
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Selection.Font.Bold = True
Selection.Font.Italic = True







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Selecting portions of a column instead of the whole colum

Gary, Thank you so much, No I don't have any blanks there and this worked
exactly as I needed.
I appreciate the assistance.
BOB

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
try this and see if it works, i don't know if you have any blank cells in
the range or not

Sub test()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
With Range("D4:D" & lastrow)
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 36
.Interior.Pattern = xlSolid
.Font.Bold = True
.Font.Italic = True
End With
End Sub


--


Gary


"BobR" wrote in message
...
Thank you Gary, Sorry I'm sorta new at this and used a record macro to
get where I am.

The active cell will need to be set and it will be set at D4. So if I
set the active cell and then then it will go down to the xlUP and select
that range??? At this point I want it to placed the background color in
these cells.
Then it will color it and make the font bold italic.

Thanks again.
Bob
"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
you don't really specify where your data starts. this should illustrate
what's actually happening, although there's a shorter way.
i assumed the active cell was in row 1. if you could be more specific
instead of using activecell, it would be better.

Sub test()
Dim lastrow As Long
lastrow = Cells(Rows.Count, ActiveCell.Offset(0,
1).Column).End(xlUp).Row
With Range(ActiveCell.Offset(0, 1).Address, Cells(lastrow,
ActiveCell.Offset(0, 1).Column).Address)
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
.Interior.ColorIndex = 36
.Interior.Pattern = xlSolid
.Font.Bold = True
.Font.Italic = True
End With
End Sub


--


Gary


"BobR" wrote in message
...
Hello, XL 2003 and 2007.
Have the code listed below that selects an entire column and then
colors and formats it. My problem is that I don't need the entire
column but only D4 down. D4 contains the beginning statement for my
pivot table. The length of the column will be variable and I'm not sure
how to put the code in to take it from D4 down to the last complete
cell.

Can someone help with the code, and the coloring is supposed to be for
the range and not the entire column
Thanks
BOB R




ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
With Selection
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
End With
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Selection.Font.Bold = True
Selection.Font.Italic = True









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
Row & column portions of a cell as variables Tigerxxx Excel Discussion (Misc queries) 5 October 17th 08 08:21 PM
Selecting more than one cell/colum with an offset statement? Fred Holmes Excel Programming 1 March 15th 07 05:16 PM
SUBTRACT COLUMN A FROM COLUM B =? kate New Users to Excel 1 August 1st 06 08:32 PM
look up a value in one column to another colum Oscar Kelley - Salmon Days Festival Excel Worksheet Functions 7 June 16th 06 03:30 AM
add a colum within 5 spaces of a column Bruce Excel Discussion (Misc queries) 2 June 9th 05 07:28 PM


All times are GMT +1. The time now is 01:51 PM.

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

About Us

"It's about Microsoft Excel"