Prevent Cut/Copy/Move Macro Code
Sep 8, 2006
I have to issue template workbooks to people for budgeting purposes.
Within the workbooks are various numbers of worksheets pre -formatted and ready for these people to enter data.
Some of the data in the worksheets is important to them as individuals but not to me so I have a series of macros that lift the information from the worksheets and put it into a worksheet more specific to me.
Because the users are on the whole not that good with Excel I have put in easy to use look up tables and various proctections to stop them adding or deleting rows or columns as this plays havoc with my macros.
There is one thing I have "so far" been unable to do and I wondered if anyone could help.
Is there a macro that I could put somewhere in the workbook which would detect when someone tried to cut and paste and would either put up a message box or stop them doing this?
The reason being they are cutting from one row to another and this is messing up the calculations which are protected.
Is there also a way to stop them changing the name on the sheet tab in the smae way?
View 9 Replies
ADVERTISEMENT
Feb 9, 2009
Is there a way to prevent access to the code of a macro? I am interested in sending out some macro's, but would prefer that the user only be able to run them, and not be able to access the code via the edit button. Curiously, there have been occasion's where I wanted to edit my own work, but the edit button did not function, so I had to exit and start over to proceed. From this I'm guessing there must be a way.
View 2 Replies
View Related
Nov 23, 2009
I'd like to know if there is a change event that only occurs when a target cell is changed by the user, but does not occur when i'ts changed by a macro. nfortunately, the Worksheet_Change event occurs in both cases.
View 2 Replies
View Related
May 8, 2009
I would like to copy or move data from one worksheet to another automatically. I have one sheet (Data) with multiple pieces of data for specific individuals. I have several other sheets titled their last name. Can data for example from John Doe be copied to the sheet Doe and data for John Smith be copied to sheet Smith. In essence I would like the sheet to paste everything below John Doe to Doe's sheet and recognize the next name and past that into the next sheet and so on. It may be several different codes, Im ok with that.
One other item all cells do not have data I do need the blank cells copied as well at to not lose the formatting. There is also a blank 2 rows between each person.
If you need a copy of what the data looks like I can send it.
View 9 Replies
View Related
Feb 8, 2007
I've developed a little software using Excel Macros & VB. To prevent people from accesing the code I protected the code blocking it from visualization. It seems not enough as an acquaintance of a friend cracked it in 25 minutes. Or so he says. So I'd like to know if there is a better way to protect the font code.
View 8 Replies
View Related
Jun 4, 2008
I need to be able to move pagebreaks in Excel by means of VBA.
I have found an example in Excel Help (see below), but it doesn't work.
Sheets("Sheet1").HPageBreaks(1).Location = Sheets("Sheet1"). Range("A24")
View 9 Replies
View Related
Apr 18, 2014
I have 'sheet 1' (data collection sheet) and 'sheet 2' (form filling sheet)
I've recorded a macro which sends data from 'sheet 2' to 'sheet 1' (linked to a submit button on 'sheet 2')
I want the macro to allow the next form filled information to be transferred onto the next line down on 'sheet 1'.
The current code is:
[Code] ......
View 4 Replies
View Related
Jul 2, 2013
I have created a few macros and once I was happy that they worked independently I joined them to run as one macro in several steps. I have just discovered a bug ...
The macro filters on a column and copies and pastes that range into another sheet.
HOwever, sometimes (as I have just discovered) when it filters, there will be no data against the value it is looking for.
I need to say, if no value, move to next step.
I.e. here's my code. It's looking for ASIA and it will copy and paste all rows with Asia to another page. It then does the same for EMEA. Thing is, in my example just now, there was no EMEA data and some times there may be no ASIA data so I need to build in some rules that if it does not find either of these it continues to finish macro or pops up and says 'NO ASIA found, CLick to continue' or something?
Selection.AutoFilter
ActiveSheet.Range("$A$12:AA" & lngLast).AutoFilter Field:=27, Criteria1:="ASIA"
Range("A13:Z" & lngLast).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("ASIA DETAIL ").Select
Range("A19").Select
[code]...
View 1 Replies
View Related
Jun 24, 2014
I need to do VBA coding. Got 12 Sheets for 12 month of Sales. Every Sheets are in same Header Format.
For Column R (Status), there's Filter Data "TRUE" and "FALSE". I have to move/copy "TRUE" item into Sheet Aging 2014.
I manage to transfer using only one Sheets using Advanced Filter VBA, failed with other Sheet.
I attached the file : Sales 2014.xlsx
View 5 Replies
View Related
May 16, 2014
Is there a code that can be input to prevent a document from being printed?
View 8 Replies
View Related
Dec 1, 2011
I have a workbook that contains macros. When the workbook is protected, the macro returns an error so I have unprotected the workbook but, if someone protects the workbook and saves it, it returns an error when closing and even if they choose cancel, it still screws up the macro and prevents it from working upon reopen.
Is there a way to prevent someone from protecting the workbook in vb code?
View 7 Replies
View Related
Aug 15, 2012
Some code that would prevent my user form (calendar) from popping up when the worksheet is protected?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$G$8" Or Target.Address = "$G$14" Or Target.Address = "$G$17" Then
CalendarFrm.Show
End If
If Target.NumberFormat = "m/d/yy;@" Then
[Code] ........
View 7 Replies
View Related
Oct 19, 2007
I know how to enable/disable events using VBA code, however is there an option within excel to turn it on/off? My problem is this...
At the beginning of my code I disable events and at the end I enable it again (I need to do this to avoid being caught in a loop). However something is going wrong somewhere in my code and the code stops halfway through. I'm trying to test sections of the code, but I often inadvertently stop the code without enabling the events again. Therefore I can't get my VBA to execute again unless I close excel down and restart. This is a pain as I have to find my place in the code again!
View 5 Replies
View Related
Apr 23, 2008
I have a spreadsheet with a number of fields on it which must be filled in before the file can be saved, and if the user attempts to close the spreadsheet without filling in the required fields, I want a message box to appear asking for confirmation that the user wishes to quit, if yes, the sheet exits, if no, the sheet remains open
View 2 Replies
View Related
Jan 2, 2012
I need multiple macros to copy information from sheet1 to sheet2 and another to copy the information from sheet1 to sheet3 and so on. need a total of 20 macros each to copy information from sheet1 and paste it to the corresponding sheet number. How to do it and this this is what i want to do, Copy roll A-B-C-D,and G but not E-F-H i have formulas that i don't want to clear or re-do every time it is possible to do this.
a B C D E F G H
HarvestDate VarietyL/P Code Label Pakagin Qty Total
1 12/2/2012 Soda 23 3
1 12/12/2012 plants 24 34
1 12/13/2012 socks 25 22
1 12/14/2012 shoes 26 22
1 12/15/2012 tie 27 22
1 12/16/2012 cds 28 22
1 12/17/2012 computer 29 22
1 12/18/2012 tapes 30 22
View 8 Replies
View Related
May 1, 2008
I have 2 workbooks that I am working out of. Workbook number 1 is where the data is going to be saved from workbook number 2. I need to copy data from workbook number 2 but there are several road blocks. 1) I need to search for specific information in column E. Anytime information is listed under this colomun it is listed 2 times one on top of the other with a different peice of information to the right of each one. note that the items that I am looking for on this sheet will no always be there.
What to copy under E / F
E F
1 BAR | $5,123
2 BAR | 24
Once the first "Bar" has been found, F1 & F2 need to be copied to workbook 1 to different locations on the active sheet. The names will always be listed together and the data will always be to the right.
View 2 Replies
View Related
Aug 14, 2014
Adding some additional code to prevent someone from saving the workbook under a different name. Currently if someone tried to enter data after the allotted time period, it would allow them to in any "unlocked" cells. When exiting or trying to save the file with this new data, they will get a message stating something to the effect that this is a read only file would you like to save as another name, which would allow the user to circumvent what I'm trying to accomplish. The end result would be they'd need a new spreadsheet.
[Code].....
View 2 Replies
View Related
May 26, 2009
Is it possible to write VBA code that will prevent a user from changing a cell's contents, depending on the cell's font color?
More specifically, I have a column of text in range B15:B64. Some of the cells will have a black font, others will be blue. Is it possible to lock the black font cells only, leaving the blue cells unlocked for users to change?
View 9 Replies
View Related
Aug 23, 2008
I am having difficulties with my Worksheet_Activate() macro. It works great within workbook1 when it is only workbook1 open - but when I open another workbook2, the macro stills runs, presumably because Sheet1 of workbook1 is still activated as well as the newly activated sheet in workbook2.
Is there a way to ensure that only 1 worksheet of 1 workbook is activated at a time? Or that sheet1 of workbook1 is deactivated when workbook2 is opened/clicked on? I need my Worksheet_Deactivate macro to run to get rid of my Worksheet_Activate macro (which runs an application that resets the function of keyboards keys). Otherwise moving around workbook2 is a nightmare. When I navigate back to workbook1 while workbook2 is still open, I still want sheet1 of workbook1 to be activated and my macro to run .
View 7 Replies
View Related
Sep 3, 2008
I have the following code that Ger Plante very kindly helped me with which, depending on whether there is an 'x' by someone's name in a list, creates a new workbook, copies some information to it and saves it before moving on to the next 'x'. Loop Through Rows & Copy Each Row To New Workbook
For lLoop = 2 To 251 'first row of data to last row.
If ws1.Cells(lLoop, 4).Value = "x" Then '4 = Column D
ws1.Activate
ws1.Range("e" & lLoop & ":g" & lLoop).Copy
ws1.Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
Rng1.Copy
Workbooks.Add
ActiveSheet.Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ActiveSheet.Range("A1").Select
ActiveSheet.SaveAs varPath & "Student Data Files" & ActiveSheet.Range("B1") & ".xls"
ActiveWorkbook.Close
Else
End If
Next lLoop
how I can modify the code such that any cells in the range "b1:b504" in Sheet1 of the the new workbook can't be selected or edited without a password....I have tried unsuccessfully using Protect but am not sure how to get vba to set it to specific cells and determine exactly what is allowed in those cells.
View 5 Replies
View Related
Dec 30, 2011
Here is the code I have:
Windows("2.xlsm").Activate
Sheets("Report_P").Select
Sheets("Report_P").Copy After:=Workbooks("New_report.xlsx").Sheets(9)
2.xlsm is open. it contains a sheet called Report_P New_report.xlsx is open and has 9 existing sheets
Every time this tries to execute I get a "Run time error 1004 Copy Method of Worksheet Failed".
What is wrong with this code? I have an identical line in another macro, the only difference is that there are 5 sheets pre-existing, and that works fine.
View 6 Replies
View Related
Apr 17, 2008
I have a long header I am pasting to a column "A" on a new Sheet. When the header pastes it is repeating itself but with long blank spaces in between each repeat. The first time goes from A1 to A152, which is all I want. But it shows up again starting at A180225, and again at A212993, and again and again. I only want a single instance of the header in Column A. Here is the macro I am using:
Sub Sort_Cells()
Rows("1:1").Select
Selection.Copy
Sheets.Add after:=Sheets(Sheets.Count)
Sheets("Sheet1").Select
Columns("A:A").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
True, Transpose:=True
Selection.Columns.AutoFit
Range("B1").Select
End Sub
View 4 Replies
View Related
Jun 5, 2008
I have created a macro with the below formula in it:
Range("L2").Select
ActiveCell.FormulaR1C1 = "=LEN(RC[-1])"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L234")
Range("L2:L234").Select
I am using column K and it looks up the length of this cell. When I created the formula I was using info that only went to line 234 which was fine. Once I clear the info in column K and input new info it can go further than line 234. How do I get the macro to look up the whole of column k without having to create a new macro each time?
View 6 Replies
View Related
Aug 28, 2013
the code always opens a new instance of Outlook even though one may already be open. If left unchecked I may have like 30 instances open if I leave the computer for a few hours. So I was wondering is there some snippet of code I can add in here to check if excel is open first and if so do not open a new instance?
Code:
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
' Change the mail address and subject in the macro before you run it.
With OutMail
.To = "xxxx@live.com"
[code].....
View 2 Replies
View Related
Aug 5, 2007
The following block of code is evaluating the term in the array, if it exists and the value in col. M is a non integer, (which what I am testing for are fractions) then format the cell to a fraction number format.
That is ok, except it is changing the numberformat on text terms. I want it only to change the numberformat on numeric values.
I added the function Isnumeric to this line:
Isnumeric(cells(i, "M").value) Int(cells(i, "M").value)
which I thought would only evaluate numeric cells only, but this was unsuccessful.
Original Code: Unedited.
For i = 4 To LRowf
For Each Item In Array("HAT", "FTWR", "BOOT", "BOOTG", "BOOTY", "HWRISR", "HWBLTS")
On Error Resume Next
If (Cells(i, "F").Value = Item Or Cells(i, "G").Value = Item) And _
Cells(i, "M").Value Int(Cells(i, "M").Value) Then
Cells(i, "M").NumberFormat = "# ?/?"
On Error GoTo 0
Exit For
'End If
End If
Next Item
Next i
View 9 Replies
View Related
Nov 18, 2009
The code itself functions as desired however i am getting the vba message "code execution has been interupted". However if i comment out the line
ActiveSheet. Range("Y6:BC6").Delete Shift:=xlUp. Then all is well - so i'd say that is the culprit.
Sub Test()
If Left(ActiveSheet.Name, 5) = "query" Then
Dim intRow As Integer
intRow = ActiveSheet.Range("Y4").End(xlDown).Offset(1, 0).Row
If intRow > 25 Then
ActiveSheet.Range("Y6:BC6").Delete Shift:=xlUp
intRow = intRow - 1
Else
End If
' Runner 1
ActiveSheet.Range("Y" & intRow).Value = ActiveSheet.Range("A5").Value
ActiveSheet.Range("Z" & intRow).Value = ActiveSheet.Range("M4").Value...................
View 6 Replies
View Related
Jul 24, 2006
Get a SUMIF formula to work, which it now does, but the formula puts '$' signs in the range, so that when it copies it, it does not change the range. I have got round this, by defining 12 separate ranges. But it does make the code rather long winded. Anyone know how to put the formula in without the '$' signs? There must be a way to put the formula into the first cell, and copy it across?
Set Rga = Range("b6")
Set Rgb = Range("b6").End(xlDown)
Set Rgd = Range("$e$6")
Set Rge = Range("$e$6").End(xlDown)
Set Rgc = Range(Cells(6, 2), Cells(6, 2).End(xlDown)).Offset(0, 3)
Set Rgh = Range(Cells(6, 5), Cells(6, 5).End(xlDown)).Offset(0, 3)
Set Rgi = Range(Cells(6, 5), Cells(6, 5).End(xlDown)).Offset(0, 4)
Set Rgj = Range(Cells(6, 5), Cells(6, 5).End(xlDown)).Offset(0, 5)
Set Rgk = Range(Cells(6, 5), Cells(6, 5).End(xlDown)).Offset(0, 6)
Set Rgl = Range(Cells(6, 5), Cells(6, 5).End(xlDown)).Offset(0, 7)
Set Rgm = Range(Cells(6, 5), Cells(6, 5).End(xlDown)).Offset(0, 8)
Set Rgn = Range(Cells(6, 5), Cells(6, 5).End(xlDown)).Offset(0, 9).............................
View 5 Replies
View Related
Apr 27, 2012
I would like to have something that will auto run the code in Module1 when the Excel File is opened, but I do not want to code tansfered into the file when it is saved in its location.
I don't mind if the code is tranfered to saved file if in fact I can make sure the code is not run when the new file is opened...
Everything is working as intended at the moment, but when openeing the saved file the entire macro tried to run again. This is what I do not want...
I currently have the following code in Module1.
Private Sub Workbook_Open()
'
' Format_Copy_&_Paste
'
Application.OnKey "^+r", "Warehouse_Cost_Summary"
'
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "DataSet"
[Code] ..........
View 4 Replies
View Related
Apr 1, 2008
how to unprotect the sheets in order to be able copying datas to to certain cells.
The unprotection works but only when I start the macro the second time. I do not understand why.
After I did the updates I want to reprotect the sheets but that seems not to work in my case.
ActiveSheet.Unprotect Password:="my_password_here"
'unprotect the sheet
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, Scenarios:=True, Password:="my_password_here"
' Reprotect the Sheet
View 7 Replies
View Related
Apr 30, 2008
I cant seem to get to work together in the same macro but that work great seperated. I need them to be in the same macro. The first just simply copy's text from one workbook to another:
Sub Test2()
ActiveSheet. Range("a1").Copy _
Destination:=Workbooks("punchlist.xls"). Sheets("Sheet1").Cells(Rows.Count,1).End(xlup).Offset(1,0)
End Sub
That worked ok but I needed to change it to the "active cell" instead of cell "a1". So then this line of code was made:
Dim userInputCell As Range
On Error Resume Next
Set userInputCell = Application.InputBox("Use the mouse to select a cell on any sheet", type:=8)
On Error Goto 0
If userInputCell Is Nothing Then
MsgBox "Cancel pressed"
Else
Msgbox "You selected " & userInputCell.Address(,,,True)
End If
The second code works just the way I want it but it doesnt copy over the text to the other workbook. I assume the 2 codes need to be together but I cant get it to work without errors. I also need the text to copy over without changing the borders on either workbook.
View 3 Replies
View Related