Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm trying to add zeroes to blank cells in ranges to make them contiguous. I have named the ranges and used the macro recorder to select the range which gives me Application.Goto Reference:="MyRange1" On Error Resume Next Selection.SpecialCells(xlBlanks).Value = 0 On Error GoTo 0 This works fine, but how can I alter it to select a number of non-contiguous at the same time. Could anyone also explain the difference between Select and the Application.Goto Reference please. Many thanks -- Diddy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This assumes that the Names have already been assign in the worksheet:
Sub zeroThem() Set r = Union(Range("myRange1"), Range("myRange2")) On Error Resume Next r.SpecialCells(xlBlanks).Value = 0 On Error GoTo 0 End Sub You do not need to either GoTo the cells or Select the cells. -- Gary''s Student - gsnu200834 "Diddy" wrote: Hi, I'm trying to add zeroes to blank cells in ranges to make them contiguous. I have named the ranges and used the macro recorder to select the range which gives me Application.Goto Reference:="MyRange1" On Error Resume Next Selection.SpecialCells(xlBlanks).Value = 0 On Error GoTo 0 This works fine, but how can I alter it to select a number of non-contiguous at the same time. Could anyone also explain the difference between Select and the Application.Goto Reference please. Many thanks -- Diddy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Gary's Student,
That works! Thank you so much -- Diddy "Gary''s Student" wrote: This assumes that the Names have already been assign in the worksheet: Sub zeroThem() Set r = Union(Range("myRange1"), Range("myRange2")) On Error Resume Next r.SpecialCells(xlBlanks).Value = 0 On Error GoTo 0 End Sub You do not need to either GoTo the cells or Select the cells. -- Gary''s Student - gsnu200834 "Diddy" wrote: Hi, I'm trying to add zeroes to blank cells in ranges to make them contiguous. I have named the ranges and used the macro recorder to select the range which gives me Application.Goto Reference:="MyRange1" On Error Resume Next Selection.SpecialCells(xlBlanks).Value = 0 On Error GoTo 0 This works fine, but how can I alter it to select a number of non-contiguous at the same time. Could anyone also explain the difference between Select and the Application.Goto Reference please. Many thanks -- Diddy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
selecting a named range based on a cell value | Excel Programming | |||
Selecting specific row/column from a named range | Excel Worksheet Functions | |||
Problem selecting a named range | Excel Programming | |||
Selecting/Printing a Named Range via VBA | Excel Programming | |||
Selecting Filtered Items from Named range | Excel Programming |