Make VBA code events work

Status
Not open for further replies.

Gtasios4

Board Regular
Joined
Apr 21, 2022
Messages
80
Office Version
  1. 2021
Platform
  1. Windows
Hi all,

I want to automate my quotation tool & protect the workbook while VBAs working.

I have dependent drop-down lists on A4:A11 and so on based on the brand list selected in cell B2. Columns A, L, N, has formulas to bring values through product info sheet.

However everything works fine on uprotected mode the opposite happens while I protect the workbook. "Insert Row" & "Delete Row" macros don't work even though I've added the below codes:

Sub macroProtect3()

Sheet1.Protect Password:="abc", UserInterFaceOnly:=True

'enter code
Sheet1.Cells(1, 1) = UCase("SOLUTION QUOTATION")

End Sub

Sub Edit_Sheet1()
'Unprotect Sheet1
Worksheets("Sheet1").Unprotect

'Do Something to Sheet1

'Reprotect Sheet1
Worksheets("Sheet1").Protect
End Sub

Sub HasFormula()

For Each Rng In ActiveSheet.Range("A4:A9")

If Rng.HasFormula Then

Rng.Locked = True

Else

Rng.Locked = False

End If

Next Rng
End Sub


Private Sub Workbook_Open()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
ws.Protect UserInterFaceOnly:=True
Next ws
End Sub


Here's my quotation tool:

1651586952194.png


I use also the below event code:

1651586899581.png


Ideally I want to keep intact the row with the "Total cost" and attach a macro by inserting row above it while using the above code.

Finally here is also the macros I use in Insert & Delete:

Sub InsertROW()
ActiveCell.EntireRow.Insert
End Sub

Sub INSERTCOPY()
With ActiveCell.EntireRow
.Copy
.Offset(1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
On Error Resume Next
.Offset(1).SpecialCells(xlCellTypeConstants).Value = ""
Application.CutCopyMode = False
On Error GoTo 0
End With
End Sub

Sub DeleteEntireRow()

Selection.EntireRow.Delete

End Sub


Any help on my thread will be much appreciated.
 

Attachments

  • 1651586832382.png
    1651586832382.png
    37.4 KB · Views: 2

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
This seems to be the same question you asked here, is it not?
 
Upvote 0
Upvote 0
Please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted. All clarificiations should be posted back to the original thread.

As per rule 12, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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