1. C

    Streamlining codes in workbook. Trying to make this more efficient.

    So I have received some awesome guidance with codes and directions to try as I continue to learn and grow in VBA and Macros. I recorded a physical macro which preps and cleans up data from a data file then imports specific columns of data to my workbook. I was thinking it might be cleaner to...
  2. S

    VBA to delete sheets loop

    Hi All, I need a script that will delete sheets based on an earlier calculation. TabDiff2 is defined earlier. I have the following code which is breaking: For v = TabDiff2 To 1 Step -1 Sheets("2_Weightings").Index -v.Select Application.DisplayAlerts = False ActiveWindow.SelectedSheets.Delete...
  3. W

    Quit current workbook, but not other active workbooks

    Hi. Got a question. I got a timer that counts from 1 min down, then runs a Sub called shutdown. The problem is, when it closes, it leaves a open empty excel program open, not completely shutting it down, i fixed this with the code under, but if i got a other workbook active, it asks that to...
  4. D

    How to close the one workbook if I have multiple workbooks open?

    Hi Team, Happy Friday! I am using following VBA code to close only the workbook I am working on, but this code closes all workbooks which have been opened. Any idea, please. Dim WbCount As Integer, ii As Integer WbCount = Workbooks.count If WbCount > 1 Then For ii = WbCount To 1 Step...
  5. P

    VBA - Save each sheet as new workbook with sheet name

    Can anyone help me with the following code i wrote: It only saves the first sheet. Sub copysheet() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets ActiveSheet.Copy wb_name = ActiveSheet.Name Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:= _...
  6. B

    Removal of Duplicates when re running the report

    Hi Guys, I hope you can help - The below is something I have built out to grab data from about 90 workbooks. The challenge I have is I need to run this each week as the data updates however this duplicates the data and I would like it to avoid this so that it only reports on the latest data...
  7. A

    Need help to simplify VB code

    Can someone help to simplify following VB code If I use something unnecessarily like "Select" etc.
  8. A

    worksheet reopening

    I am using the code at the end of this post to make the sheet autosave every x minutes. The autosave function works perfectly. The issue is if there is another excel file open at the time of close the autosave sheet reopens at the time it would have saved. There is another excel file that...
  9. N

    For Each wb VBA Issues

    I have a code I've been working on to open files in a folder and see if they meet certain criteria. If so it copies it to another sheet where I am organizing the data I want. The issue I am having is when it finds a file that does not meet the criteria it just ends the code and doesn't continue...
  10. M

    Run Time Error 9 on Deleting sheet

    In trying to delete a sheet, I constantly get run-time error 9. I think the reason is because the code called to delete the sheet originates from within a button on the sheet; kinda-sorta like suicide prevention. To Try to avoid this, I placed code in the activate event of another sheet and...
  11. S

    Save As of copied sheets is very slow

    Hi folks, My code populates 5 sheets before making a copy for a new workbook, then save as, then email. The save as part is very slow. I've stepped through it and it lags for 30 seconds. Has anybody seen this before? I haven't had much luck on google. All help appreciated! This is the...
  12. sharky12345

    Open each hyperlink in new IE tab

    I'm using this to loop through cells containing hyperlinks to websites and if criteria is met open that page; Application.DisplayAlerts = FalseFor Each Cell In Sheet11.Range("J2:J19") If Cell.Value = "YES" Then If Cell.Offset(0, 3) > 13 Then ThisWorkbook.FollowHyperlink Cell.Offset(0, -7)...
  13. R

    Compile Error: Expected Expression

    Hi all, getting this expected expression error, it's highlighting the IF part, though I don't know why: Sub FinalEnqCopydown() ' ' Copydown Macro ' ' If ActiveCell.Row < 3 Then MsgBox "Select Last Row in Data" Else Application.ScreenUpdating = False Application.DisplayAlerts = False...
  14. W

    VBA Code for Saving Workbook not working

    I am creating an Archive macro that when pressed will send a worksheet from one workbook to another. Currently the code will open the workbook and send the worksheet and then delete it from the original workbook. The problem I am having is saving the destination workbook after it has been...
  15. H

    VBA code for stopping the save promt box from poping up

    I am running a VBA code to convert several excel files and I am needing to get the pop up prompt to stop showing. This is the code I am working with Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:"E\bob_smith\Done.txt" FileFormat:=xlText Application.DisplayAlerts = True I...
  16. P

    Application.Quit doesn't work

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Dim sh As Worksheet Application.DisplayAlerts = False For Each sh In ThisWorkbook.Sheets Select Case sh.Name Case "Exhibit " & """I"" ", "page 2" Call...
  17. J


    I am hoping someone can help me simplify this... I have multiple tabs each I have a separate macro calling for each tab to be written to a directory in a shared network location. I feel that this could be a lot cleaner... Also I need it to not run copy the file over if J4 is blank on any of...
  18. B

    Autosave messes with my VBA solution

    With AutoSave ON: I must close the active workbook after saving as .xlsx Then, copy the active workbook again, Delete the unnecessary columns and SaveAs the .cvs Otherwise, AutoSave performs the deletion and Autofit on the original copied worksheet. This code works, but seems kind of...
  19. J

    Combining Sheets from Network Location

    I am currently attempting to combine multiple sheets from a network location into one sheet. It looks to process everything okay until the actual output of the final combined worksheet. I am a little lost as to where it is going wrong. I did remove the file location of where our server is...
  20. S

    vba for sumif formula

    Hello, Whats wrong with my sumif function? Sub update2()Dim x As Workbook Dim y As Workbook ImportDir1 = Trim(Sheets("Control").Range("H6").Value) Application.DisplayAlerts = False Set x = Workbooks.Open(ImportDir1 & "\" & Sheets("Control").Range("C6").Value & ".xlsx") With x.Sheets(1)...

Watch MrExcel Video

This Week's Hot Topics

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back