Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Seamus2626
at 2024-11-18 09:06:42
Point:500 Replies:31 POST_ID:828810USER_ID:11690
Topic:
Microsoft Excel Spreadsheet Software;;
Hi,
I get the warning "unprotected formula" in a yellow box in the top left hand corner of my vlookups etc, i manually click on these to ignore, can i do this using VBA
My sub is below
Many thanks
--------------------------------
Sub FillOutFomrula()
Dim LastR As Long
Sheets("D2 Data").Select
With ActiveSheet
LastR = .Cells(.Rows.Count, "A").End(xlUp).Row
Range("DW2").Formula = "=VLOOKUP(B2,'Calculation D2'!A:BG,29,0)"
Range("DX2").Formula = "=VLOOKUP(D2,'Lookup tables'!$C$5:$E$30,2,0)"
Range("DY2").Formula = "=CONCATENATE(DQ2,"" to "",DW2)"
Range("DZ2").Formula = "=IF(OR(DY2=""STANDARD to Standard"",DY2=""MEDIUM to medium"",DY2=""HIGH to High""),""No Change"",DY2)"
Range("EA2").Formula = "='Calculation D2'!AM2"
Range("EB2").Formula = "='Calculation D2'!AS2"
Range("EC2").Formula = "='Calculation D2'!AU2"
Range("ED2").Formula = "='Calculation D2'!BG2"
Range("DW2:ED2").AutoFill Destination:=Range("DW2:ED" & LastR)
End With
Sheets("Analysis").Select
AllWorksheetPivots
MsgBox "Analysis Ready"
End Sub
I get the warning "unprotected formula" in a yellow box in the top left hand corner of my vlookups etc, i manually click on these to ignore, can i do this using VBA
My sub is below
Many thanks
--------------------------------
Sub FillOutFomrula()
Dim LastR As Long
Sheets("D2 Data").Select
With ActiveSheet
LastR = .Cells(.Rows.Count, "A").End(xlUp).Row
Range("DW2").Formula = "=VLOOKUP(B2,'Calculation D2'!A:BG,29,0)"
Range("DX2").Formula = "=VLOOKUP(D2,'Lookup tables'!$C$5:$E$30,2,0)"
Range("DY2").Formula = "=CONCATENATE(DQ2,"" to "",DW2)"
Range("DZ2").Formula = "=IF(OR(DY2=""STANDARD to Standard"",DY2=""MEDIUM to medium"",DY2=""HIGH to High""),""No Change"",DY2)"
Range("EA2").Formula = "='Calculation D2'!AM2"
Range("EB2").Formula = "='Calculation D2'!AS2"
Range("EC2").Formula = "='Calculation D2'!AU2"
Range("ED2").Formula = "='Calculation D2'!BG2"
Range("DW2:ED2").AutoFill Destination:=Range("DW2:ED" & LastR)
End With
Sheets("Analysis").Select
AllWorksheetPivots
MsgBox "Analysis Ready"
End Sub
Author: Seamus2626 replied at 2024-11-22 01:21:03
That makes sense ssaqibh, will remember that going fwd, thanks
Expert: Saqib Husain, Syed replied at 2024-11-22 01:14:00
Apparently you have not got a solution to your problem and that is why you have given a B grade. If this is the case then it would have been better to delete the question instead of accepting as it is misleading to anyone reading this question in future.
Expert: Saqib Husain, Syed replied at 2024-11-21 11:19:29
You might like to consider using the
Private Sub Workbook_Activate()
and the
Private Sub Workbook_Deactivate()
event handlers to enable/disable the error checking.
Private Sub Workbook_Activate()
and the
Private Sub Workbook_Deactivate()
event handlers to enable/disable the error checking.
Author: Seamus2626 replied at 2024-11-21 11:02:37
So if you go to excel options, then formulas, you will see a sextion for error checking rules.
There is 9 of them including the error "unlocked cells containing formula"
I want would like to in essence turn that option off for a user, so they dont have the error messages, but yet i dont want to change their settings, so only want that error not to display for the instance they use my spreadsheet
Does that make sense?!
There is 9 of them including the error "unlocked cells containing formula"
I want would like to in essence turn that option off for a user, so they dont have the error messages, but yet i dont want to change their settings, so only want that error not to display for the instance they use my spreadsheet
Does that make sense?!
Expert: Saqib Husain, Syed replied at 2024-11-21 10:39:31
Is there a way I can see the error happening? I am at a loss as to what is happening.
Author: Seamus2626 replied at 2024-11-21 10:33:40
YOu see the uploaded file is going to have ref and value errors where i have got rid of the underlying data
So for my purposes i can just untick the option in error checking for "unprotected Formula" in options. But in other peoples spreadsheets they will have that option automatically checked, so it will show the error sign
Its not one of the #NA, REF errors etc, its the error that just says the formula is not protected
So for my purposes i can just untick the option in error checking for "unprotected Formula" in options. But in other peoples spreadsheets they will have that option automatically checked, so it will show the error sign
Its not one of the #NA, REF errors etc, its the error that just says the formula is not protected
Expert: Saqib Husain, Syed replied at 2024-11-21 10:22:17
Do you get the error message on the real file only or the uploaded file as well?
Author: Seamus2626 replied at 2024-11-21 10:09:44
Its not for me,
the error message "unprotected Formula" is still in all the cells in the range
the error message "unprotected Formula" is still in all the cells in the range
Expert: Saqib Husain, Syed replied at 2024-11-21 10:00:05
The macro is working just fine. It stops only at
Sheets("Analysis").Select
because there is no sheet called Analysis.
Sheets("Analysis").Select
because there is no sheet called Analysis.
Author: Seamus2626 replied at 2024-11-21 09:54:27
Yep, this is all you need i think
Thanks
Seamus
Thanks
Seamus
Expert: Saqib Husain, Syed replied at 2024-11-21 09:49:57
Is there any way to upload a sample which demonstrates the problem?
Author: Seamus2626 replied at 2024-11-21 09:45:14
Spelling looks good and i have no option explicit
Sub FillOutFomrula()
Dim LastR As Long
Dim aCell As Range, i As Long
Set aCell = ActiveCell
Set aRange = ActiveWorkbook.Names("Range").RefersToRange
Sheets("D2 Data").Select
With ActiveSheet
LastR = .Cells(.Rows.Count, "A").End(xlUp).Row
Range("DW2").Formula = "=VLOOKUP(B2,'Calculation D2'!A:BG,29,0)"
Range("DX2").Formula = "=VLOOKUP(D2,'Lookup tables'!$C$5:$E$30,2,0)"
Range("DY2").Formula = "=CONCATENATE(DQ2,"" to "",DW2)"
Range("DZ2").Formula = "=IF(OR(DY2=""STANDARD to Standard"",DY2=""MEDIUM to medium"",DY2=""HIGH to High""),""No Change"",DY2)"
Range("EA2").Formula = "='Calculation D2'!AM2"
Range("EB2").Formula = "='Calculation D2'!AS2"
Range("EC2").Formula = "='Calculation D2'!AU2"
Range("ED2").Formula = "='Calculation D2'!BG2"
Range("DW2:ED2").AutoFill Destination:=Range("DW2:ED" & LastR)
End With
For Each aCell In aRange.Cells
For i = 1 To 8
aCell.Errors(i).Ignore = bIgnore
Next
Next
Sheets("Analysis").Select
AllWorksheetPivots
MsgBox "Analysis Ready"
End Sub
Sub FillOutFomrula()
Dim LastR As Long
Dim aCell As Range, i As Long
Set aCell = ActiveCell
Set aRange = ActiveWorkbook.Names("Range").RefersToRange
Sheets("D2 Data").Select
With ActiveSheet
LastR = .Cells(.Rows.Count, "A").End(xlUp).Row
Range("DW2").Formula = "=VLOOKUP(B2,'Calculation D2'!A:BG,29,0)"
Range("DX2").Formula = "=VLOOKUP(D2,'Lookup tables'!$C$5:$E$30,2,0)"
Range("DY2").Formula = "=CONCATENATE(DQ2,"" to "",DW2)"
Range("DZ2").Formula = "=IF(OR(DY2=""STANDARD to Standard"",DY2=""MEDIUM to medium"",DY2=""HIGH to High""),""No Change"",DY2)"
Range("EA2").Formula = "='Calculation D2'!AM2"
Range("EB2").Formula = "='Calculation D2'!AS2"
Range("EC2").Formula = "='Calculation D2'!AU2"
Range("ED2").Formula = "='Calculation D2'!BG2"
Range("DW2:ED2").AutoFill Destination:=Range("DW2:ED" & LastR)
End With
For Each aCell In aRange.Cells
For i = 1 To 8
aCell.Errors(i).Ignore = bIgnore
Next
Next
Sheets("Analysis").Select
AllWorksheetPivots
MsgBox "Analysis Ready"
End Sub
Expert: Saqib Husain, Syed replied at 2024-11-21 09:42:24
If you do not have option explicit set then the program will work even without the dim
also make sure that you have the spelling correct. Is it Arange or Arrange?
also make sure that you have the spelling correct. Is it Arange or Arrange?
Author: Seamus2626 replied at 2024-11-21 09:35:23
Dim LastR As Long
Dim aCell As Range, i As Long
Is this part of the sub correct, where does it set Arange as a data type?
Thanks
Dim aCell As Range, i As Long
Is this part of the sub correct, where does it set Arange as a data type?
Thanks
Author: Seamus2626 replied at 2024-11-21 09:30:38
=OFFSET('D2 Data'!$DW$2,0,0,COUNTA('D2 Data'!$DW:$DW),8)
that works fine, that is returning the correct range of data
The problem is line
Set Arrange = ActiveWorkbook.Names("Range").RefersToRange
It is not setting Arrange correctly
Thanks
that works fine, that is returning the correct range of data
The problem is line
Set Arrange = ActiveWorkbook.Names("Range").RefersToRange
It is not setting Arrange correctly
Thanks
Expert: Saqib Husain, Syed replied at 2024-11-21 09:08:19
Put a stop before the line
Set Arrange = ActiveWorkbook.Names("Range").RefersToRange
and break down the formula
=OFFSET('D2 Data'!$DW$2,0,0,COUNTA('D2 Data'!$DW:$DW),8)
and see what each component is returning.
Set Arrange = ActiveWorkbook.Names("Range").RefersToRange
and break down the formula
=OFFSET('D2 Data'!$DW$2,0,0,COUNTA('D2 Data'!$DW:$DW),8)
and see what each component is returning.
Author: Seamus2626 replied at 2024-11-21 08:28:22
It says
<expression not defined in context>
Thanks
<expression not defined in context>
Thanks
Expert: Saqib Husain, Syed replied at 2024-11-21 08:00:44
Instead of hovering the mouse, try selecting the Arange and press Shift-F9 to see what is happening.
Author: Seamus2626 replied at 2024-11-21 06:53:50
Its my range, its not reading my range.
I have a dynamic offset range
=OFFSET('D2 Data'!$DW$2,0,0,COUNTA('D2 Data'!$DW:$DW),8)
That works fine and picks up the correct range.
When i hover over Arange in the code, it does not have anything there, whereas aCell refers to the current cell, is there anything wrong with my offset or is there any reason why the range is not being found?
Many thanks
I have a dynamic offset range
=OFFSET('D2 Data'!$DW$2,0,0,COUNTA('D2 Data'!$DW:$DW),8)
That works fine and picks up the correct range.
When i hover over Arange in the code, it does not have anything there, whereas aCell refers to the current cell, is there anything wrong with my offset or is there any reason why the range is not being found?
Many thanks
Assisted Solution
Expert: Saqib Husain, Syed replied at 2024-11-20 08:54:26
166 points GOOD
The code worked just fine with meon the given sheet. It only stopped at
Sheets("Analysis").Select
because there was no sheet with that name.
Sheets("Analysis").Select
because there was no sheet with that name.
Author: Seamus2626 replied at 2024-11-20 00:39:43
Thanks byundt, that never fixed the errors
Attached is the ss, i have removed sensitive data, so currently the lookups etc have ref errors, but with the correct data, it is the "unprotected formula error"
Many thanks
Seamus
Attached is the ss, i have removed sensitive data, so currently the lookups etc have ref errors, but with the correct data, it is the "unprotected formula error"
Many thanks
Seamus
Expert: byundt replied at 2024-11-19 13:00:28
Try declaring Arrange:
If that doesn't fix the problem, could you please post a sample workbook that replicates the problem?
Author: Seamus2626 replied at 2024-11-19 01:02:55
Hi all,
My sub is being stopped at
For Each aCell In Arrange.Cells
Error is "object doesnt support property or method"
The named range is working, so im not sure what the error is about....
many thanks
--------------------------------------
Sub FillOutFomrula()
Dim LastR As Long
Dim aCell As Range, i As Long
Set aCell = ActiveCell
Set Arrange = ActiveWorkbook.Names("Range").RefersToRange
Sheets("D2 Data").Select
With ActiveSheet
LastR = .Cells(.Rows.Count, "A").End(xlUp).Row
Range("DW2").Formula = "=VLOOKUP(B2,'Calculation D2'!A:BG,29,0)"
Range("DX2").Formula = "=VLOOKUP(D2,'Lookup tables'!$C$5:$E$30,2,0)"
Range("DY2").Formula = "=CONCATENATE(DQ2,"" to "",DW2)"
Range("DZ2").Formula = "=IF(OR(DY2=""STANDARD to Standard"",DY2=""MEDIUM to medium"",DY2=""HIGH to High""),""No Change"",DY2)"
Range("EA2").Formula = "='Calculation D2'!AM2"
Range("EB2").Formula = "='Calculation D2'!AS2"
Range("EC2").Formula = "='Calculation D2'!AU2"
Range("ED2").Formula = "='Calculation D2'!BG2"
Range("DW2:ED2").AutoFill Destination:=Range("DW2:ED" & LastR)
End With
For Each aCell In Arrange.Cells
For i = 1 To 8
aCell.Errors(i).Ignore = bIgnore
Next
Next
Sheets("Analysis").Select
AllWorksheetPivots
MsgBox "Analysis Ready"
End Sub
My sub is being stopped at
For Each aCell In Arrange.Cells
Error is "object doesnt support property or method"
The named range is working, so im not sure what the error is about....
many thanks
--------------------------------------
Sub FillOutFomrula()
Dim LastR As Long
Dim aCell As Range, i As Long
Set aCell = ActiveCell
Set Arrange = ActiveWorkbook.Names("Range").RefersToRange
Sheets("D2 Data").Select
With ActiveSheet
LastR = .Cells(.Rows.Count, "A").End(xlUp).Row
Range("DW2").Formula = "=VLOOKUP(B2,'Calculation D2'!A:BG,29,0)"
Range("DX2").Formula = "=VLOOKUP(D2,'Lookup tables'!$C$5:$E$30,2,0)"
Range("DY2").Formula = "=CONCATENATE(DQ2,"" to "",DW2)"
Range("DZ2").Formula = "=IF(OR(DY2=""STANDARD to Standard"",DY2=""MEDIUM to medium"",DY2=""HIGH to High""),""No Change"",DY2)"
Range("EA2").Formula = "='Calculation D2'!AM2"
Range("EB2").Formula = "='Calculation D2'!AS2"
Range("EC2").Formula = "='Calculation D2'!AU2"
Range("ED2").Formula = "='Calculation D2'!BG2"
Range("DW2:ED2").AutoFill Destination:=Range("DW2:ED" & LastR)
End With
For Each aCell In Arrange.Cells
For i = 1 To 8
aCell.Errors(i).Ignore = bIgnore
Next
Next
Sheets("Analysis").Select
AllWorksheetPivots
MsgBox "Analysis Ready"
End Sub
Assisted Solution
Expert: byundt replied at 2024-11-18 18:05:10
167 points GOOD
If you have a dynamic named range called myDynamicNamedRange, you could use:
Author: Seamus2626 replied at 2024-11-18 10:27:15
Thanks ssaqibh, for the range, am i able to use a dynamic named range
eg
Set arange = Range
where range is a dynamic named range
Thanks
Seamus
eg
Set arange = Range
where range is a dynamic named range
Thanks
Seamus
Expert: Saqib Husain, Syed replied at 2024-11-18 10:14:31
set acell = activecell
Author: Seamus2626 replied at 2024-11-18 09:26:25
That looks really good, im just struggling to work in acell and arange
I tried acell = activecell but that wont work
Do you know how i define the cell and the range?
The range will change according to
Range("DW2:ED2").AutoFill Destination:=Range("DW2:ED" & LastR)
Any advice?
Thanks
Seamus
I tried acell = activecell but that wont work
Do you know how i define the cell and the range?
The range will change according to
Range("DW2:ED2").AutoFill Destination:=Range("DW2:ED" & LastR)
Any advice?
Thanks
Seamus
Expert: Anthony Berenguel replied at 2024-11-18 09:19:01
Good post @write2mohit! I will definitely make use of this in the future!
Accepted Solution
Expert: write2mohit replied at 2024-11-18 09:16:09
167 points GOOD
You don't want to disable to Alerts instead implement this in your code
Sub IgnoreErrCheckingOnRange(aRange As Range, bIgnore As Boolean) '-- This switch off/on all 8 types of error checking on each cell in a specified range. Dim aCell As Range, i As Long For Each aCell In aRange.Cells For i = 1 To 8 aCell.Errors(i).Ignore = bIgnore Next NextEnd SubSub Test() IgnoreErrCheckingOnRange Sheet1.Range("A1:B10"), TrueEnd Sub 1:2:3:4:5:6:7:8:9:10:11:12:13:14:
Code found in vbforums posted by anhn.
Expert: Anthony Berenguel replied at 2024-11-18 09:14:48
Also, I would recommend turning the warnings back on at the end of your code
'before you code executesApplication.DisplayAlerts = False'your code'after your code executresApplication.DisplayAlerts = True 1:2:3:4:5:6:7:
Expert: duncanb7 replied at 2024-11-18 09:09:45
Add this on the top of your code or before your code
Application.DisplayAlerts = False