VBA Error 6 unknown cause

amineact

New Member
Joined
Apr 12, 2022
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hello There, I'm sort of a newbie to VBA. I'm trying to set up a macro thatv will enable me to export a whole workbook each tilme i change the parameters;
For some time, the code was working fine but nom it's giving me Error 6, which i dont know the cause.
I would very much appreciate the help.
Here's the code.
VBA Code:
Sub MySave23()

    Dim ws As Worksheet
    
'   Look through each sheet and hard-code formulas
    For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
    Next ws
    
'   Save workbook
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs ActiveWorkbook.Path & "\Filename_" & Format(Date, "dd-mmm-yy") & ".xlsb", xlExcel12
    Application.DisplayAlerts = True
    
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Your codes seems no problem. Have you some data in some sheet with too long strings or too large numbers?
 
Upvote 0
Solution
Your codes seems no problem. Have you some data in some sheet with too long strings or too large numbers?
hey there
sorry for the late reply, your answer was right as i had too much large account numbers and vba was treating them as integer while in fact they should be treated as Long type
Thanks for the help
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,603
Members
449,089
Latest member
Motoracer88

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 MrExcel.com.
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 "mrexcel.com".
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
Back
Top