my Menu bars and my scroll bar in excel have been turned off - do not show, how do I…
- User
my Menu bars and my scroll bar in excel have been turned off - do not show, how do I reset them back to show
- Assistant
To reset your menu bars and scroll bar in Excel:
- Click on the "File" menu in the top left corner of Excel.
- Click on "Options" at the bottom left of the menu.
- In the Excel Options dialog box, click on "Advanced" in the left pane.
- Scroll down to the "Display options for this workbook" section.
- Ensure that the "Show horizontal scroll bar" and "Show vertical scroll bar" options are checked.
- Check the "Show Mini Toolbar on selection" option if you want to see a small toolbar when selecting cells.
- Click "OK" to save your changes.
Your menu bars and scroll bars should now be visible in Excel.
- User
I want to write a vba code that does the following: On SelectionChange of Cell A38, it will take the values of E3, F3, B7 and append it to B38 as a Concatenated value with a space between each value, the it will 'SAVE AS' the excel document to a specific folder and close. How do I do this
- Assistant
You can use the following VBA code to achieve this:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$38" Then ' Check if cell A38 is selected Dim strConcat As String strConcat = Range("E3").Value & " " & Range("F3").Value & " " & Range("B7").Value Range("B38").Value = strConcat ' Concatenate and write to B38 ' Define the save path and filename Dim folderPath As String folderPath = "C:\Users\YourUserName\Documents\SaveFolder\" ' Change this to your desired file path Dim fileName As String fileName = "MySavedFile.xlsx" ' Change this to your desired file name with extension ' Save the file and close Excel ThisWorkbook.SaveAs folderPath & fileName Application.Quit End If End SubThis code should be added to the worksheet module where the data is located. To do this, follow these steps:
- Right-click on the worksheet tab where the data is located.
- Click "View Code" to open the VBA editor.
- Paste the above code into the editor.
- User
On Application.Quit will it close other instances of Excel that are open
- Assistant
No,
Application.Quitwill only close the instance of Excel that is currently running the code. If you have multiple instances of Excel open, this code will only close the instance that has the particular workbook with this code open.If you want to close all instances of Excel, you can use the following code instead of
Application.Quit:Sub CloseAllExcelInstances() Dim objXLApp As Object Dim objXLWbs As Object ' Loop through all running instances of Excel For Each objXLApp In GetObject(, "Excel.Application").Application ' Loop through all workbooks in each Excel instance For Each objXLWbs In objXLApp.Workbooks If objXLWbs.Saved = True Then ' Save and close workbooks that are saved objXLWbs.Close savechanges:=True Else ' Close unsaved workbooks without saving objXLWbs.Close savechanges:=False End If Next objXLWbs ' Quit each Excel instance after all workbooks have been closed objXLApp.Quit Next objXLApp End Sub - User
Sorry I forgot to mention, On SelectionChange of Cell A38, it will take the values of E3, F3, B7 and append it to B38 as a Concatenated value with a space between each value, the it will ‘SAVE AS’ the excel document to a specific folder using the Concatenated value as the new file name
- Assistant
You can use the following modified VBA code to achieve this:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$38" Then ' Check if cell A38 is selected Dim strConcat As String strConcat = Range("E3").Value & " " & Range("F3").Value & " " & Range("B7").Value Range("B38").Value = strConcat ' Concatenate and write to B38 ' Define the save path and filename Dim folderPath As String folderPath = "C:\Users\YourUserName\Documents\SaveFolder\" ' Change this to your desired file path Dim fileName As String fileName = strConcat & ".xlsx" ' Use the concatenated values as the file name with extension ' Save the file and close Excel ThisWorkbook.SaveAs folderPath & fileName Application.Quit End If End SubThis code is similar to the previous one, except that it uses the concatenated value as the file name when saving the file. The file name is created by appending ".xlsx" to the concatenated value. Note that this assumes that the concatenated value does not contain any characters that are not allowed in file names, such as slashes or asterisks.
- User
Can we also do this, if E3, F3, or B7 is blank then it will pop up a message and exit the sub. I also forgot to mention that it should also print just before saving
- Assistant
You can modify the previous code as follows to check if E3, F3, or B7 is blank and display a message before exiting the sub:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$38" Then ' Check if cell A38 is selected ' Check if any of the required cells are blank If Range("E3") = "" Or Range("F3") = "" Or Range("B7") = "" Then ' Display an error message and exit the sub MsgBox "Please fill in all required fields before saving." Exit Sub End If ' Concatenate the values of E3, F3, and B7 with a space between each value Dim strConcat As String strConcat = Range("E3").Value & " " & Range("F3").Value & " " & Range("B7").Value Range("B38").Value = strConcat ' Write the concatenated value to B38 ' Define the save path and filename Dim folderPath As String folderPath = "C:\Users\YourUserName\Documents\SaveFolder\" ' Change this to your desired file path Dim fileName As String fileName = strConcat & ".xlsx" ' Use the concatenated value as the file name ' Print the sheet before saving ActiveSheet.PrintOut ' Save the file and close Excel ThisWorkbook.SaveAs folderPath & fileName Application.Quit End If End Sub - User
Im getting an error on - ThisWorkbook.SaveAs folderPath & fileName
- Assistant
- User
How do I write the VBA code on WorkBook Open, Sheet 'Permit H' Cells F3, B6, B38, ClearContents
- Assistant
You can use the following VBA code in the Workbook_Open event to clear the contents of cells F3, B6, and B38 in the "Permit H" sheet:
- Open the VBA Editor by pressing Alt + F11.
- In the left pane of the VBA Editor, double-click on the "ThisWorkbook" object to open its code module.
- Copy and paste the following code into the module:
Private Sub Workbook_Open() ' Clear the contents of cells F3, B6, and B38 in the "Permit H" sheet With ThisWorkbook.Sheets("Permit H") .Range("F3").ClearContents .Range("B6").ClearContents .Range("B38").ClearContents End With End Sub- Save and close the VBA Editor.
- Save the workbook as a macro-enabled file (.xlsm).
Note: This code assumes that the name of the sheet where you want to clear cells is "Permit H". If the name of the sheet is different, you should modify the sheet name in the code.