i want to copy the original column to the next column then hide column hide the first column

bhandari

Active Member
Joined
Oct 17, 2017
Messages
359
http://tinypic.com/r/amdso7/9
9

My code is only working when it is unprotcted,i wanto work my code when it is protected

i have added my macro to 2 pictures
1 picture to add columns
2.Code not working properly

9
iam attaching here with image which is protected.

Code:
Sub addcolumns1()
Dim numcol As String
numcol = InputBox("Enter number of columns to insert:", _
  "Number of Column?")
If numcol = "" Then
    MsgBox ("No value entered")
    Exit Sub
End If
Range("S1").Resize(, numcol).EntireColumn.Insert
Columns(18).EntireColumn.Copy Range("S1").Resize(, numcol)


End Sub

As well as i am looking for deleting the entire column which is added by above code by input box
 
Last edited:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
you can add a line to unprotect the worksheet as the code runs and then re-protect so that no one messes anything up.

Here is a code another user posted to get the lines for the protect/unprotect


Rich (BB code):
Sub ProtectAll
Dim
Rich (BB code):
Rich (BB code):
 sh As Worksheet
Dim myPassword AsString
myPassword = "password"

ForEach sh In ActiveWorkbook.Worksheets
sh.Protect Password:=myPassword
Next sh

EndSub

Sub UnprotectAll()
Dim sh As Worksheet
Dim myPassword AsString
myPassword = "password"

ForEach sh In ActiveWorkbook.Worksheets
sh.Unprotect Password:=myPassword
Next sh

End Sub

 
Last edited:
Upvote 0
Thnaks for your code,its working propely.
but i dont want to protect complete sheet,some of the columns need to unprotect
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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