Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Lookup cells in one column and clear cells in another

I need a macro to lookup the cells in column "N" that equal zero and clear
all corresponding cells in columns "M" and "J".
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Lookup cells in one column and clear cells in another

Josh
Do you mean those cells in Column N that have a zero ("0") in them or
those cells that have a mathematical value of zero? Note that a blank cell
has a mathematical value of zero. HTH Otto
"JoshW0000" wrote in message
...
I need a macro to lookup the cells in column "N" that equal zero and clear
all corresponding cells in columns "M" and "J".



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Lookup cells in one column and clear cells in another

Otto,

I mean the cells that have "0" as a mathematical value. Basically, I'm
dragging and dropping formulas in thousands of cells in columns "J" and "M"
and there is to be a space in between each group. The cells in column "N"
will be blank. I just need a macro to clear "J" and "M" where "N" is blank.

Sorry I should have been more specific.

"Otto Moehrbach" wrote:

Josh
Do you mean those cells in Column N that have a zero ("0") in them or
those cells that have a mathematical value of zero? Note that a blank cell
has a mathematical value of zero. HTH Otto
"JoshW0000" wrote in message
...
I need a macro to lookup the cells in column "N" that equal zero and clear
all corresponding cells in columns "M" and "J".




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Lookup cells in one column and clear cells in another

Josh
This little macro will do that. I assumed your data starts in Row 2.
Sub ClearJM()
Dim LastRow As Long, LastJ As Long
Dim LastM As Long, rColN As Range
Dim i As Range, rJM As Range
Set rJM = Range("J1,M1")
LastJ = Range("J" & Rows.Count).End(xlUp).Row
LastM = Range("M" & Rows.Count).End(xlUp).Row
LastRow = Application.Max(LastJ, LastM)
Set rColN = Range("N2", Range("N" & LastRow))
For Each i In rColN
If IsEmpty(i.Value) Then
rJM.Offset(i.Row - 1).ClearContents
End If
Next i
End Sub
"JoshW0000" wrote in message
...
Otto,

I mean the cells that have "0" as a mathematical value. Basically, I'm
dragging and dropping formulas in thousands of cells in columns "J" and
"M"
and there is to be a space in between each group. The cells in column "N"
will be blank. I just need a macro to clear "J" and "M" where "N" is
blank.

Sorry I should have been more specific.

"Otto Moehrbach" wrote:

Josh
Do you mean those cells in Column N that have a zero ("0") in them or
those cells that have a mathematical value of zero? Note that a blank
cell
has a mathematical value of zero. HTH Otto
"JoshW0000" wrote in message
...
I need a macro to lookup the cells in column "N" that equal zero and
clear
all corresponding cells in columns "M" and "J".






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Lookup cells in one column and clear cells in another

Otto,

It's telling me "Compile Error: Expected End Sub". Any suggestions?

"Otto Moehrbach" wrote:

Josh
This little macro will do that. I assumed your data starts in Row 2.
Sub ClearJM()
Dim LastRow As Long, LastJ As Long
Dim LastM As Long, rColN As Range
Dim i As Range, rJM As Range
Set rJM = Range("J1,M1")
LastJ = Range("J" & Rows.Count).End(xlUp).Row
LastM = Range("M" & Rows.Count).End(xlUp).Row
LastRow = Application.Max(LastJ, LastM)
Set rColN = Range("N2", Range("N" & LastRow))
For Each i In rColN
If IsEmpty(i.Value) Then
rJM.Offset(i.Row - 1).ClearContents
End If
Next i
End Sub
"JoshW0000" wrote in message
...
Otto,

I mean the cells that have "0" as a mathematical value. Basically, I'm
dragging and dropping formulas in thousands of cells in columns "J" and
"M"
and there is to be a space in between each group. The cells in column "N"
will be blank. I just need a macro to clear "J" and "M" where "N" is
blank.

Sorry I should have been more specific.

"Otto Moehrbach" wrote:

Josh
Do you mean those cells in Column N that have a zero ("0") in them or
those cells that have a mathematical value of zero? Note that a blank
cell
has a mathematical value of zero. HTH Otto
"JoshW0000" wrote in message
...
I need a macro to lookup the cells in column "N" that equal zero and
clear
all corresponding cells in columns "M" and "J".








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Lookup cells in one column and clear cells in another

Nevermind Otto, it was a "ID10T" error. The macro works great! Thanks!

"Otto Moehrbach" wrote:

Josh
This little macro will do that. I assumed your data starts in Row 2.
Sub ClearJM()
Dim LastRow As Long, LastJ As Long
Dim LastM As Long, rColN As Range
Dim i As Range, rJM As Range
Set rJM = Range("J1,M1")
LastJ = Range("J" & Rows.Count).End(xlUp).Row
LastM = Range("M" & Rows.Count).End(xlUp).Row
LastRow = Application.Max(LastJ, LastM)
Set rColN = Range("N2", Range("N" & LastRow))
For Each i In rColN
If IsEmpty(i.Value) Then
rJM.Offset(i.Row - 1).ClearContents
End If
Next i
End Sub
"JoshW0000" wrote in message
...
Otto,

I mean the cells that have "0" as a mathematical value. Basically, I'm
dragging and dropping formulas in thousands of cells in columns "J" and
"M"
and there is to be a space in between each group. The cells in column "N"
will be blank. I just need a macro to clear "J" and "M" where "N" is
blank.

Sorry I should have been more specific.

"Otto Moehrbach" wrote:

Josh
Do you mean those cells in Column N that have a zero ("0") in them or
those cells that have a mathematical value of zero? Note that a blank
cell
has a mathematical value of zero. HTH Otto
"JoshW0000" wrote in message
...
I need a macro to lookup the cells in column "N" that equal zero and
clear
all corresponding cells in columns "M" and "J".






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
Clear cells in a column that contain 0 jasontferrell Excel Programming 0 July 27th 09 04:38 PM
Create a Clear button to clear unprotected cells Jcraig713 Excel Programming 2 November 26th 07 03:55 PM
Clear cells in Column D if not = Auto JOUIOUI Excel Programming 5 June 11th 06 01:34 PM
How do I clear a column of data without clearing specific cells? EllenSwarts Excel Discussion (Misc queries) 2 April 5th 06 05:07 PM
lookup value then clear some cells Y Sbuty Excel Programming 6 September 27th 05 09:34 PM


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

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"