Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default If B1 = 0 then D1= True - I need to write this in a macro

Hi All

I was hoping that someone may be able to help me.
Basically if I have cell with a value 0, with a click of
a button a macro will check all the values in that column
(B1) for the value 0, and place a value (True) in column
D1. can you lep?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default If B1 = 0 then D1= True - I need to write this in a macro

To test (say) rows 1 to 20:

Sub mytest()
Dim rRow As Long
For rRow = 1 To 20
If Not (IsEmpty(Cells(rRow, 2))) And _
Cells(rRow, 2).Value = 0 Then Cells(rRow, 4).Value = True
Next rRow
End Sub



wrote in message
...
Hi All

I was hoping that someone may be able to help me.
Basically if I have cell with a value 0, with a click of
a button a macro will check all the values in that column
(B1) for the value 0, and place a value (True) in column
D1. can you lep?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default If B1 = 0 then D1= True - I need to write this in a macro

Private Sub CommandButton1_Click()
Dim rng as Range, cell as Range
if activecell.Column = 4 then exit sub
if activeCell.Value = 0 and not isempty(activecell) then
set rng = Range(Cells(1,activecell.column), _
cells(rows.count,activecell.column).End(xlup))
for each cell in rng
if not isempty(cell) and cell.value = 0 then
cells(cell.row,4).Value = True
end if
Next
End if
End Sub

Put a commandbutton on the sheet from the control toolbox toobar.

right click on the sheet tab and select view code.

Put in code like the above (rename commandbutton1 to match the name of the
commandbutton) in the resulting module.

--
Regards,
Tom Ogilvy




wrote in message
...
Hi All

I was hoping that someone may be able to help me.
Basically if I have cell with a value 0, with a click of
a button a macro will check all the values in that column
(B1) for the value 0, and place a value (True) in column
D1. can you lep?



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default If B1 = 0 then D1= True - I need to write this in a macro

A massive THANK-YOU!!!!

You're a star and a great help!!!!

it worked a treat!

Cheers
Sanj



-----Original Message-----
To test (say) rows 1 to 20:

Sub mytest()
Dim rRow As Long
For rRow = 1 To 20
If Not (IsEmpty(Cells(rRow, 2))) And _
Cells(rRow, 2).Value = 0 Then Cells(rRow, 4).Value =

True
Next rRow
End Sub



wrote in message
...
Hi All

I was hoping that someone may be able to help me.
Basically if I have cell with a value 0, with a click

of
a button a macro will check all the values in that

column
(B1) for the value 0, and place a value (True) in

column
D1. can you lep?



.

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
Write a formula for a penalty for status of TRUE? Esperanza Excel Worksheet Functions 4 February 14th 10 01:08 PM
Read lines from one worksheet, if value is true, write to new work Bernie Excel Discussion (Misc queries) 2 March 15th 07 11:27 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
If "true" run a Macro Rod Excel Worksheet Functions 4 March 17th 05 08:14 PM
comparing data and write values if true Jon-Henrik Excel Programming 2 November 28th 03 09:01 AM


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