![]() |
Inconsistent code
For fCtr = LBound(PrintFiles) To UBound(PrintFiles)
Set PrintFiles(fCtr) = Workbooks.Open _ (FileName:=PrintFileNames(fCtr)) Range("A1").Select 'If it's the first workbook in the loop, and if the user wants to 'hide the same Column(s): If fCtr = 1 Then If Global_HideSameCols = True Then 'On Error Resume Next * Set Global_ExclColRng = Application.InputBox("Use the left mouse " & _ "button with the Control key," & vbNewLine & "to select at least" _ & " one cell in each column " & vbNewLine & "(or the entire" _ & ".column), to indicate those" & vbNewLine & "Columns to be" _ & " hidden. Click OK. when done", Type:=8) 'On Error GoTo 0 End If End If 'But user might still want to hide a Column(s) in individual workbooks, so: If HideCols = True Then If Global_HideSameCols = False Then 'On Error Resume Next * Set Wkbk_ExclColRng = Application.InputBox("This is a test", Type:=8) If I direct the code through the first Set statement and select a range to hide, then the code executes ok. If I direct it through the second Set statement, I get an 'Object required' message. Why is the code not working, and why is it inconsistent, please? Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
Inconsistent code
You get an error if the user hits cancel since the inputbox returns false
instead of a range you can't set Global_ExclColRng = False that is why the error handlers are there (you commented them out). They catch the error and ignore it. You then have to test the object to see if it was set if Global_ExclColRng is nothing then msgbox "You clicked cancel" End if -- Regards, Tom Ogilvy "Stuart" wrote in message ... For fCtr = LBound(PrintFiles) To UBound(PrintFiles) Set PrintFiles(fCtr) = Workbooks.Open _ (FileName:=PrintFileNames(fCtr)) Range("A1").Select 'If it's the first workbook in the loop, and if the user wants to 'hide the same Column(s): If fCtr = 1 Then If Global_HideSameCols = True Then 'On Error Resume Next * Set Global_ExclColRng = Application.InputBox("Use the left mouse " & _ "button with the Control key," & vbNewLine & "to select at least" _ & " one cell in each column " & vbNewLine & "(or the entire" _ & ".column), to indicate those" & vbNewLine & "Columns to be" _ & " hidden. Click OK. when done", Type:=8) 'On Error GoTo 0 End If End If 'But user might still want to hide a Column(s) in individual workbooks, so: If HideCols = True Then If Global_HideSameCols = False Then 'On Error Resume Next * Set Wkbk_ExclColRng = Application.InputBox("This is a test", Type:=8) If I direct the code through the first Set statement and select a range to hide, then the code executes ok. If I direct it through the second Set statement, I get an 'Object required' message. Why is the code not working, and why is it inconsistent, please? Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
Inconsistent code
I understand. Many thanks.
Regards. "Tom Ogilvy" wrote in message ... You get an error if the user hits cancel since the inputbox returns false instead of a range you can't set Global_ExclColRng = False that is why the error handlers are there (you commented them out). They catch the error and ignore it. You then have to test the object to see if it was set if Global_ExclColRng is nothing then msgbox "You clicked cancel" End if -- Regards, Tom Ogilvy "Stuart" wrote in message ... For fCtr = LBound(PrintFiles) To UBound(PrintFiles) Set PrintFiles(fCtr) = Workbooks.Open _ (FileName:=PrintFileNames(fCtr)) Range("A1").Select 'If it's the first workbook in the loop, and if the user wants to 'hide the same Column(s): If fCtr = 1 Then If Global_HideSameCols = True Then 'On Error Resume Next * Set Global_ExclColRng = Application.InputBox("Use the left mouse " & _ "button with the Control key," & vbNewLine & "to select at least" _ & " one cell in each column " & vbNewLine & "(or the entire" _ & ".column), to indicate those" & vbNewLine & "Columns to be" _ & " hidden. Click OK. when done", Type:=8) 'On Error GoTo 0 End If End If 'But user might still want to hide a Column(s) in individual workbooks, so: If HideCols = True Then If Global_HideSameCols = False Then 'On Error Resume Next * Set Wkbk_ExclColRng = Application.InputBox("This is a test", Type:=8) If I direct the code through the first Set statement and select a range to hide, then the code executes ok. If I direct it through the second Set statement, I get an 'Object required' message. Why is the code not working, and why is it inconsistent, please? Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
All times are GMT +1. The time now is 07:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com