Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Macro to delete 0

Is it possible to record something along the lines of

If Active.Cell = 0, then delete all 0s in column C - Y (for that same row only

The active cell would always be in column b
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to delete 0


With Activecell
If .Value = 0 Then
Range("C" & .Row & ":Y" & .Row"").Replace What:="0", _
Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
End WIth


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hargrove" wrote in message
...
Is it possible to record something along the lines of

If Active.Cell = 0, then delete all 0s in column C - Y (for that same row

only)

The active cell would always be in column b



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Macro to delete 0

When I entered this into the macro, from the word
Range ("C"... through.... MatchCase:=False
shows up in red and the "" after the second Row is highlighted.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to delete 0

Sorry, some extra ""

With ActiveCell
If .Value = 0 Then
Range("C" & .Row & ":Y" & .Row).Replace What:="0", _
Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hargrove" wrote in message
...
When I entered this into the macro, from the word
Range ("C"... through.... MatchCase:=False
shows up in red and the "" after the second Row is highlighted.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Macro to delete 0


If I wanted to be able to select several cells, could ActiveCell be replaced with SelectedCells or something along the lines
----- Bob Phillips wrote: ----


With Activecel
If .Value = 0 The
Range("C" & .Row & ":Y" & .Row"").Replace What:="0",
Replacement:="",
LookAt:=xlWhole,
SearchOrder:=xlByRows,
MatchCase:=Fals
End I
End WIt


--

HT

Bob Phillip
... looking out across Poole Harbour to the Purbeck
(remove nothere from the email address if mailing direct

"Hargrove" wrote in messag
..
Is it possible to record something along the lines o
If Active.Cell = 0, then delete all 0s in column C - Y (for that same ro

only
The active cell would always be in column






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to delete 0

No, you would need to lop through them, but make sure only the cells in
column B are selected

For Each cell In Selection
If cell.Value = 0 Then
Range("C" & cell.Row & ":Y" & cell.Row"").Replace
What:="0", _
Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
Next cell


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hargrove" wrote in message
...

If I wanted to be able to select several cells, could ActiveCell be

replaced with SelectedCells or something along the lines?
----- Bob Phillips wrote: -----


With Activecell
If .Value = 0 Then
Range("C" & .Row & ":Y" & .Row"").Replace What:="0",

_
Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
End WIth


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hargrove" wrote in message
...
Is it possible to record something along the lines of
If Active.Cell = 0, then delete all 0s in column C - Y (for that

same row
only)
The active cell would always be in column b






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Macro to delete 0

Hi
try

dim rng as range
dim cell as range
set rng = selection
for each cell in rng
With cell
If .Value = 0 Then
Range("C" & .Row & ":Y" & .Row).Replace What:="0", _
Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
End With
next



--
Regards
Frank Kabel
Frankfurt, Germany


Hargrove wrote:
If I wanted to be able to select several cells, could ActiveCell
be replaced with SelectedCells or something along the lines?
----- Bob Phillips wrote: -----


With Activecell
If .Value = 0 Then
Range("C" & .Row & ":Y" & .Row"").Replace
What:="0", _ Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
End WIth


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hargrove" wrote in

message
...
Is it possible to record something along the lines of
If Active.Cell = 0, then delete all 0s in column C - Y (for

that same row only)
The active cell would always be in column b


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to delete 0

oops that mistake again

For Each cell In Selection
If cell.Value = 0 Then
Range("C" & cell.Row & ":Y" & cell.Row).Replace _
What:="0", _
Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
Next cell


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
No, you would need to lop through them, but make sure only the cells in
column B are selected

For Each cell In Selection
If cell.Value = 0 Then
Range("C" & cell.Row & ":Y" & cell.Row"").Replace
What:="0", _
Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
Next cell


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hargrove" wrote in message
...

If I wanted to be able to select several cells, could ActiveCell be

replaced with SelectedCells or something along the lines?
----- Bob Phillips wrote: -----


With Activecell
If .Value = 0 Then
Range("C" & .Row & ":Y" & .Row"").Replace

What:="0",
_
Replacement:="", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False
End If
End WIth


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hargrove" wrote in message
...
Is it possible to record something along the lines of
If Active.Cell = 0, then delete all 0s in column C - Y (for that

same row
only)
The active cell would always be in column b








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
Macro warning - how to delete macro GavinS Excel Worksheet Functions 3 April 1st 09 01:45 PM
delete a macro that isn't in macro list Jane Makinson Excel Discussion (Misc queries) 3 March 13th 06 01:10 PM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


All times are GMT +1. The time now is 10:58 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"