gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
Write an Excel VBA script to close all open windows except the first
- User
Write an Excel VBA script to close all open windows except the first
- Assistant
Sub CloseAllWindowsExceptFirst()
Dim i As Integer
For i = 2 To Windows.Count Windows(i).Close Next i
End Sub
- User
That returns an error, I need Excel to cycle through all open windows of a worksheet named SMB Planning Tool and close all except for the parent/base window
- Assistant
Sure, you can modify the code as follows to achieve this:
Sub CloseAllWindowsExceptMain() Dim wb As Workbook Dim ws As Worksheet Dim win As Window Set wb = ThisWorkbook Set ws = wb.Sheets("SMB Planning Tool") Set win = ws.Parent.Windows(1) For i = ws.Parent.Windows.Count To 2 Step -1 If Not ws.Parent.Windows(i) Is win Then ws.Parent.Windows(i).Close End If Next i End SubThis code should close all windows in the workbook except for the first window of the "SMB Planning Tool" worksheet.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.