View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
okanem[_6_] okanem[_6_] is offline
external usenet poster
 
Posts: 1
Default Macro - IF command


I managed to put the code per order sheet on one line so I can just
remove one ' to activate new orders that are on the system instad of
four or five '

Anyway, here is my code for the first few orders that are already
there. I have 10000 lines of code in the macro, each line accounting
for a new order number, from 50054.xls onward to 60000.xls are all
remed out using a ' before the Workbooks.Open command as I have
demonstrated for 50002.xls.

Workbooks.Open
Filename:="\\Ctserver\common\Hawk\System\Orders\50 000.xls",
ReadOnly:=True: Sheets("Hide").Visible = True: Sheets("Hide").Select:
Range("A4:BB4").Select: Selection.Copy:
Windows("hawkmasterrep.xls").Activate: Sheets("Data").Select:
Range("A4").Select: Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False:
Windows("50000.xls").Activate: Application.CutCopyMode = False:
ActiveWorkbook.Close (False)

Workbooks.Open
Filename:="\\Ctserver\common\Hawk\System\Orders\50 001.xls",
ReadOnly:=True: Sheets("Hide").Visible = True: Sheets("Hide").Select:
Range("A4:BB4").Select: Selection.Copy:
Windows("hawkmasterrep.xls").Activate: Sheets("Data").Select:
Range("A5").Select: Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False:
Windows("50001.xls").Activate: Application.CutCopyMode = False:
ActiveWorkbook.Close (False)

' Workbooks.Open
Filename:="\\Ctserver\common\Hawk\System\Orders\50 002.xls",
ReadOnly:=True: Sheets("Hide").Visible = True: Sheets("Hide").Select:
Range("A4:BB4").Select: Selection.Copy:
Windows("hawkmasterrep.xls").Activate: Sheets("Data").Select:
Range("A6").Select: Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False:
Windows("50002.xls").Activate: Application.CutCopyMode = False:
ActiveWorkbook.Close (False)


All they do is simply open a read only 50000.xls or 50001.xls etc then
unhide a sheet called 'Hide', copy and paste special one line of data
(A4 to BB4) into consecutive rows in the hawkmasterreport.xls, then it
closes the 5000?.xls sheet.

So what I am after is if the order sheet, lets say 50008.xls, isnt in
the orders folder then the macro does not attempt to open it without me
having to go in and make sure the line has a ' at the start of it.

Hope someone can help.

Rgds
Okanem


--
okanem
------------------------------------------------------------------------
okanem's Profile: http://www.excelforum.com/member.php...fo&userid=9301
View this thread: http://www.excelforum.com/showthread...hreadid=558216