#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 25
Default macro needed please

i need a macro that will when run will put a number 1 in cell A1 but if there
is already a number 1 i want the same macro to enter a 0 (zero) i supose its
a bit like a switch. To sum up exactly what i need.... If there is a 0 (zero)
i want the macro to enter a 1 in cell A1 and then print page 1 of my "output"
worksheet. If there is already a 1 in A1 then i want it to enter a 0 (zero)
with no print.

Sorry if this seems silly but it really would be useful in what im trying to
achieve
p.s. the macro will run when i click an auto shape thats assigned to it
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 698
Default macro needed please

Maybe something like this...

Sub ZeroOrOne()

If Range("A1").Value = 0 Then
Range("A1").Value = 1
ActiveWindow.SelectedSheets.PrintOut
ElseIf Range("A1").Value = 1 Then
Range("A1").Value = 0
End If

End Sub

HTH
Regards,
Howard

"jackrobyn1" wrote in message
...
i need a macro that will when run will put a number 1 in cell A1 but if
there
is already a number 1 i want the same macro to enter a 0 (zero) i supose
its
a bit like a switch. To sum up exactly what i need.... If there is a 0
(zero)
i want the macro to enter a 1 in cell A1 and then print page 1 of my
"output"
worksheet. If there is already a 1 in A1 then i want it to enter a 0
(zero)
with no print.

Sorry if this seems silly but it really would be useful in what im trying
to
achieve
p.s. the macro will run when i click an auto shape thats assigned to it
Thanks



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default macro needed please



"jackrobyn1" wrote:

i need a macro that will when run will put a number 1 in cell A1 but if there
is already a number 1 i want the same macro to enter a 0 (zero) i supose its
a bit like a switch. To sum up exactly what i need.... If there is a 0 (zero)
i want the macro to enter a 1 in cell A1 and then print page 1 of my "output"
worksheet. If there is already a 1 in A1 then i want it to enter a 0 (zero)
with no print.

Sorry if this seems silly but it really would be useful in what im trying to
achieve
p.s. the macro will run when i click an auto shape thats assigned to it
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default macro needed please

Here's one approach:

sub Switch()
cells(1, 1) = abs(cells(1, 1) - 1)
if cells(1, 1) = 1 then
'Call your print routine - you can record a macro if needed.
end if
end sub

Note that if cell(1, 1) contains 1, then 1 - 1 = 0, and the absolute value
of 0 = 0. If the cell contains 0 then 0 - 1 = -1 and the absolute value of
-1 is 1. So, you've got your switch.

"jackrobyn1" wrote:

i need a macro that will when run will put a number 1 in cell A1 but if there
is already a number 1 i want the same macro to enter a 0 (zero) i supose its
a bit like a switch. To sum up exactly what i need.... If there is a 0 (zero)
i want the macro to enter a 1 in cell A1 and then print page 1 of my "output"
worksheet. If there is already a 1 in A1 then i want it to enter a 0 (zero)
with no print.

Sorry if this seems silly but it really would be useful in what im trying to
achieve
p.s. the macro will run when i click an auto shape thats assigned to it
Thanks

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 help needed :( [email protected] Excel Worksheet Functions 2 April 7th 08 03:06 PM
Macro Help Needed sb1920alk Excel Discussion (Misc queries) 0 December 7th 07 09:54 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


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