Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Selecting an offset of a range of visible cells, but only those <0?

XL2003
I have the following code, which works fine; it copies a group of visible
cells (containing names) and transposes it on another sheet.

Sheet11.Range("D7:IV7").SpecialCells(xlCellTypeVis ible).Copy
Sheet7.Range("A1").PasteSpecial xlPasteValues, , , True

This works fine, because the cells to the right of the names are blank, so
they show up blank on the destination sheet

Now I need to grab the "scores" for each person, which are in row 45, but I
only want to bring over the relevant range (columns with names). Every cell
in row 45 has a formula (more names are added on an ongoing basis), so all
the cells beyond the last column with a name just evaluate to zero. If I use
the code as-is and just copy over D45:IV45, I get those extra zeros down the
page. I don't want to hide the extra columns in Sheet11 because other pieces
of code add and pull data that the user needs to see, and that would be a
lot of code checking.

Is there a way to limit the copy range above to not only visible cells, but
cells <0? If so, then I assume I could just use an offset to also grab the
scores from the visible columns.

Any advice greatly appreciated!
Thanks,
Keith


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting an offset of a range of visible cells, but only those <0?

Hard to follow your explanation, but sounds like your code should hide the
columns/rows you don't want, do the copy and paste, then unhide the columns.



Dim rng as Range, rng1 as Range
set rng = sheet11.Range("D45:IV45").SpecialCells(xlformulas)

for each cell in rng
if cell.value = 0 then
if rng1 is nothing then
set rng1 = cell
else
set rng1 = union(rng1,cell)
end if
end if
Next
if not rng1 is nothing then
rng1.Entirecolumn.Hidden = true
end if
Sheet11.Range("D7:IV45").Copy
Sheet7.Range("A1").PasteSpecial xlPasteValues, , , True
if not rng1 is nothing then
rng1.EntireColumn.Hidden = False
End if


--
Regards,
Tom Ogilvy




--
Regards,
Tom Ogilvy


"Keith" wrote in message
...
XL2003
I have the following code, which works fine; it copies a group of visible
cells (containing names) and transposes it on another sheet.

Sheet11.Range("D7:IV7").SpecialCells(xlCellTypeVis ible).Copy
Sheet7.Range("A1").PasteSpecial xlPasteValues, , , True

This works fine, because the cells to the right of the names are blank, so
they show up blank on the destination sheet

Now I need to grab the "scores" for each person, which are in row 45, but
I only want to bring over the relevant range (columns with names). Every
cell in row 45 has a formula (more names are added on an ongoing basis),
so all the cells beyond the last column with a name just evaluate to zero.
If I use the code as-is and just copy over D45:IV45, I get those extra
zeros down the page. I don't want to hide the extra columns in Sheet11
because other pieces of code add and pull data that the user needs to see,
and that would be a lot of code checking.

Is there a way to limit the copy range above to not only visible cells,
but cells <0? If so, then I assume I could just use an offset to also
grab the scores from the visible columns.

Any advice greatly appreciated!
Thanks,
Keith



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Selecting an offset of a range of visible cells, but only those <0?

Sorry about the confusion- and thanks for the help, I'll try your solution.
Keith

"Tom Ogilvy" wrote in message
...
Hard to follow your explanation, but sounds like your code should hide the
columns/rows you don't want, do the copy and paste, then unhide the
columns.



Dim rng as Range, rng1 as Range
set rng = sheet11.Range("D45:IV45").SpecialCells(xlformulas)

for each cell in rng
if cell.value = 0 then
if rng1 is nothing then
set rng1 = cell
else
set rng1 = union(rng1,cell)
end if
end if
Next
if not rng1 is nothing then
rng1.Entirecolumn.Hidden = true
end if
Sheet11.Range("D7:IV45").Copy
Sheet7.Range("A1").PasteSpecial xlPasteValues, , , True
if not rng1 is nothing then
rng1.EntireColumn.Hidden = False
End if


--
Regards,
Tom Ogilvy




--
Regards,
Tom Ogilvy


"Keith" wrote in message
...
XL2003
I have the following code, which works fine; it copies a group of visible
cells (containing names) and transposes it on another sheet.

Sheet11.Range("D7:IV7").SpecialCells(xlCellTypeVis ible).Copy
Sheet7.Range("A1").PasteSpecial xlPasteValues, , , True

This works fine, because the cells to the right of the names are blank,
so they show up blank on the destination sheet

Now I need to grab the "scores" for each person, which are in row 45, but
I only want to bring over the relevant range (columns with names). Every
cell in row 45 has a formula (more names are added on an ongoing basis),
so all the cells beyond the last column with a name just evaluate to
zero. If I use the code as-is and just copy over D45:IV45, I get those
extra zeros down the page. I don't want to hide the extra columns in
Sheet11 because other pieces of code add and pull data that the user
needs to see, and that would be a lot of code checking.

Is there a way to limit the copy range above to not only visible cells,
but cells <0? If so, then I assume I could just use an offset to also
grab the scores from the visible columns.

Any advice greatly appreciated!
Thanks,
Keith





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
Selecting offset cells Zygan Excel Discussion (Misc queries) 2 June 4th 06 10:03 AM
Problem with Range.Cells.Offset and Range.Cells( row + offset, column) [email protected] Excel Programming 2 August 22nd 05 05:25 AM
Selecting a Range from an Offset for deletion - Help please MichaelC Excel Programming 5 June 13th 05 11:31 PM
Selecting a range offset from a cell Beeegr8 Excel Programming 2 April 1st 05 08:02 PM
Selecting cell using range.offset presence76[_3_] Excel Programming 2 June 9th 04 03:46 PM


All times are GMT +1. The time now is 02:20 AM.

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"