Unlocking Cell After Macro Runs

Dec 17, 2009

I have a macro in my worksheet that runs as a change event on certain comment cells. This macro unprotects the worksheet, expands the merged comment cell that just change, and re-protects the worksheet. The cell expansion works great. When I re-protect the worksheet all of the cells work correctly, except the cell that was just changed. Any other "unlocked" cell in the document stays unlocked after the protection is applied, but the cell that just changed becomes locked. I need this cell to remain unlocked to allow the user to update the comments. Here is my full

View 3 Replies


ADVERTISEMENT

Macro Is Unlocking Locked Cells

May 7, 2008

I'm using three different workbooks for the macro I've designed. The macro works exactly as I planned it would, but I'm getting a curious side-effect of running the macro. I have over 5,000 workbooks that I need to open, unprotect, change (mostly by copy/paste), and reprotect. It's a fairly straight forward macro, but it is my first, and I must be overlooking something. When the macro is complete, cells that were not modified via the macro in any planned/anticipated way are being unlocked. This has left me puzzled and frustrated. The files are opened, unprotected, the cells are copied over as planned, reprotected, and closed/saved. Everything works perfectly, but the cells in parts of the workbook (Filename) (which were locked before the macro ran) have been unlocked and are no longer protected when the workbook is reprotected. Again, these cells were not within the ranges modified, and I'd rather not have to format every cell in every one of the 5 sheets of (Filename) to be locked.

File names are:
"Finished Goods Inventory TREE (ToDMSI).xls" (alias: Workfile - sheet providing file path to be updated)
"Random_workbook_selected_from_previous_filename.xls" (alias: FileName - the copy-to file being updated)
"MACRO TEST BOM Master.xls" (the copy-from file always open)

Comma Delimited table layout in "Finished Goods Inventory TREE (ToDMSI).xls":
Col A, Col B, Col C, Col D
Customer ID,Item Code,File Name, Directory
4FRE01,4FRE01-0001,4FRE01-0001.xls,4FRONT

Here's the

Public FileName

Public Workfile

Public ItemCode

Public CustCode

Sub OpenBOMSeq()

View 14 Replies View Related

Macro To Move A Cell Right Every Time It Runs

Mar 12, 2008

I have a spreadsheet with sales figures for a company over a few months. I want to create a macro that will insert a new month after the last month. I have got it to work for the first month but after that it will just insert 2 black cells after.

i have a named cell called Average_slales_per_month that is next to the last month all the time.

View 9 Replies View Related

Macro Runs When I Click On Specific Cell.

Aug 19, 2009

how would i make a macro run when i click on a specific cell?

View 4 Replies View Related

Unlocking A Cell To Edit It

Feb 22, 2008

i have an excel sheet that has a cell with a formula in it. This cell has been locked by the previous user.

I am unable to click on it and it because it is showing a #NAME? error, i need to edit it somehow. Is there some way i can edit it?

View 9 Replies View Related

VBA Code Not Unlocking Cell

Jun 7, 2014

I have this code:

Code:
Private Sub WorkSheet_Activate()
'Open workbook and default all main page dynamic data
Application.EnableEvents = False
With Worksheets("MAIN")
.Unprotect
.Range("F3").Value = ""
.Range("O5,T5, F6") = ""

[code]....

It is triggered when protected worksheet "MAIN" is activated. EnableEvents=False prevents any worksheet change triggers as cells are defaulted. Ranges F3. O5, T5, and F6 are cleared. Rows 5 and 6 are hidden (to be revealed again in later code).

Cell F3 is a cell in which user input is required via a validation list. Since the worksheet is protected, it is necessary to unlock range F3 to allow the user to enter data in the cell. EnableEvents is set backto true to allow the worksheet change to trigger when the user enters data in F3.

I am receiving an 'Application-defined or object-defined error' with the line highlighted in red above. (the line that is supposed to unlock cell F3)

View 3 Replies View Related

Locking And Unlocking Range Based On Another Cell

Jan 29, 2007

I have copied from another post (here I believe) and modified for my situtation. I simply want a range of cells K13:U13 to stay locked unless there is an X in H13. This will repeat on down the spreadsheet, ie. K14:U14 will stay locked unless there is a X in H14. Using the script I found it seems to be working unless you go back and change one of the X's to a blank. The range stays unlocked.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim strName As String
Dim strRange As String
strName = Me.Range("H13")
If strName = "" Then
Me.Cells.Locked = True
Me.Range("H13").Locked = False
End If
strName = Me.Range("H14")
If strName = "" Then
Me.Cells.Locked = True
Me.Range("H14").Locked = False
End If..................................

View 6 Replies View Related

Unlocking Locked Cells Based On Other Cell Text

Jul 5, 2012

I need to unlock and lock certain cells when other cells have data entered.

I also need to enforce in the unlocked cells a minimum value.

In my worksheet i have the below requirement

Initially Cells C6 and 7 are unlocked and Cells C5, 8 and 9 are locked

1. Cell C6 must have a value entered greater than or equal to 50, when this value is entered I need to unlock cells C5 and C9 and lock cell C7
2. Cell C7 must have a value entered greater than or equal to 50, when this value is entered I need to unlock cells C5 and C8 and lock cell C6

I also need to unlock cells C15 and 16 when C13 has "Yes" selected in the drop down menu.

View 3 Replies View Related

Creating A Macro, That Creates A New Button, Which Itself Runs A Macro..

Dec 15, 2009

I have a long complicated macro that processes a ton of data and gives the output in a new sheet. I then want to create new buttons (or some sort of user clickable triggers) on this new sheet that runs another macro.

I have got the actual adding of buttons in the sheet working, but I can't find a way to automatically assign macros to newly generated buttons during runtime. Is this even possible (or are there any clever tricks I could use to get around this?)

View 3 Replies View Related

Building Macro That Runs Another Macro Based On Certain Columns

Jun 6, 2012

Essentially, I am working with a database for a school and up until this point, each row matches up to a student with a bunch of information on them. One of these pieces of info is their parent's names. This is a much simplified look at things, but the screenshot below is a basic version of what everything looks like:

Now, the school wants me to split up the parents names from the student's and place them in their own row. I have recorded a macro to do this where you make the active cell the "full name" column for the row you want to expand, and then run the macro. Afterwards, up to two more rows are added, with the parent's names and some data copied. Below is a screenshot of what that looks like: (yellow is the new data generated, and blue is the active cell I marked to run the macro properly)

The issue is that there are thousands of these that need to be done, and I figured there is a way to do this with a macro. The issue is that not every row has parents names to expand out.

In layman's terms, I need a macro that will look at the two columns titled "Father's Name" and "Mother's Name" on each row of the spreadsheet and then, if there is any data in both or either of them, it should set the active cell to the "Full Name" column for that row then run the macro accordingly. After that it should repeat this all the way down, skipping any where neither of the columns have text in them

In the actual spreadsheet, the columns that need to be checked are AW and AX, and the column that needs to be set to the active cell before running the macro is B.

View 5 Replies View Related

Macro That Takes Workbooks Or Files And Runs Them Through Another Macro

Apr 25, 2007

i need to make a macro that takes workbooks or files and
runs them through another macro. i already have the 2nd macro
done and it is working perfectly i just need to know how to make the one
that finds the other files and runs them all through the macro i already made. My boss said that he will have about 150-200 files to run through this macro.

View 9 Replies View Related

Macro Only Runs Once

Nov 28, 2009

I can't seem to find an answer for this, but as an alternative, on Worksheet Activate the code runs and places a 1 in Range("A1") and therefore the next time the macro will not run.

This works fine for me, but just thinking if somebody who doesn't know why the one is in A1 and deletes it this macro will run again on sheet activate.

Private Sub Worksheet_Activate()
Dim LR As Long
Dim rng As Range

If Sheets("Charts").Range("A1").Value = 1 Then Exit Sub

LR = Sheets("POD").Cells(Rows.Count, "B").End(xlUp).Row

With Sheets("Charts")
.Range("I129").FormulaR1C1 = "=ROWS(R1C1:R[-128]C[-8])"
Set rng = .Range("A129").Resize(, 10)
rng.Copy rng.Resize(LR - 4)...............

View 9 Replies View Related

Macro Only Runs Manually

Feb 5, 2008

Running Windows XP; Excel 2003

I have a fairly simply macro.

It copies certain sheets out of a workbook (for a new workbook)
Unprotect the sheets in the new workbook
Deletes a particular cell on each sheet
Unhides a sheet
Sets all of the new worksheets to normal view
Protects the new sheets
Lets the user save and name the new workbook.

All is working fine Except it will not change the new workbook from Page Break View to Normal view.

The code I'm using = Sheets("name").Activate
Activewindow.View=xlNormal

Here's the strangest part. When I run the macro from a command button, the newly created workbook retains the page break view (as is in the original).

When I run the macro line by line via F8, IT WORKS JUST FINE

View 9 Replies View Related

Macro Runs For A Bit And Then Crashes

Feb 15, 2008

I have created a macro in xl2000 which was working fine - although through corporate upgrades my machine has now been upgraded with xl2003 and the macro runs for a bit and then crashes on the code below, although it only highlights teh 'rnum'

rnum = ActiveCell.Row
Is there a difference between xl2000 & xl2003?

View 9 Replies View Related

Macro Runs Slow

Nov 13, 2008

The code below runs on a spreadsheet that has approx 600 rows which INDEX and MATCH another spreadsheet which has approx 600 rows. I takes about 4 mins to run.
Sub QC()

Range("T1").Select
ActiveCell.FormulaR1C1 = "Compared CCCD"
Range("V4").Select
Columns("T:T").ColumnWidth = 15.29
Range("S1").Select
Selection.Copy
Range("T1").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Columns("T:T").Select...................

View 9 Replies View Related

Turn Autocalculation Off While Macro Runs

Mar 11, 2009

I have a macro which reads data from a large number (up to 500) of books in a folder. This extracted information is subject to some fairly heavy analysis which means that the macro runs very slowly as the sheet is constantly calculating.

I would like to add some code - maybe after 'screen updating = false' - that would turn off auto calculation while the macro runs and then restore it once the macro is finished.

View 3 Replies View Related

Open Workbook Macro Only Runs Once..

Jun 30, 2009

i have a button on my workbook1 that opens another workbook (lets call it workbook2) and automatically runs a macro on opening it. Once opened i have a button on workbook2 to close itself. I then go back to see workbook1. This all works but then when i click on the button to open the workbook2 again it opens but the macro does not run.

View 4 Replies View Related

Macro That Effectively Runs All The Time

Jul 20, 2009

Is it possible to have a macro which effectively runs all the time.

For example, if the user imputs something which is wrong I want the macro to pick it up straight away with a message box.

View 13 Replies View Related

Splash Screen While Macro Runs?

Sep 24, 2009

I searched for this and found a few examples on splash screens, but if someone could help I would appreciate it.

Basically I have this massive macro that runs, I recorded some of it, and VBA the rest. It does a bunch of things like bringing in different spreadsheets, formatting vlookups blah blah blah... Anyway for a nice touch I was hoping that I could get a splash screen or something that will run while this macro is running in the background. How hard would this be? The macro is button driven...

View 9 Replies View Related

Run A Macro That Only Runs On The Filtered Data

Jan 11, 2007

I have a spreadsheet that is made up of single line items with sub-totals at various points going down the sheet (ie the spreadsheet is split into sections)

Each section is about 100 rows long and 40 columns wide, 10 of which are sub-totals, all using the same formula from that i enter in column A.

As i add new sections i have recorded a simple macro that copies the active cell (ie A15 for example). It then pastes into D15, F15, H15, N15, X15 and then returns to A15.
I have linked this up to ctrl X for ease of running.

I have around 500 section totals to "ctrl X", per spreadsheet and 10 spreadsheets to do in total. I have firstly filtered all the line items (rows) out to leave me just the sub-totals to [ctrl x] [arrow down] [ctrl x] [arrow down] [ctrl x] etc etc etc....
Is there anyway to automate this process, i have tried recording another macro of me [ctrl x] [arrow down] about 30 times, but when i run it, it pastes on the hidden rows, not just on what you see on the screen. Is there a bit of code i can enter so it only sees what is visible.??

View 9 Replies View Related

Macro Only Runs In Step-Thru Mode

Sep 11, 2006

I have a peice of code which opens up a number of Workbooks (200+) and updates a series of control tables in each. Given our security etc environment, links and external references etc are not possible. The target files must all be standalone and self-sufficient.

The problem I have is that when I run the procedure in question in the usual way, the procedure simply terminates after the first file is opened. No error messages, no distress - it just stops. I have put debugging calls all around the "Workbook.Open" call, and it simply doesn't make it out of the call. There is no Auto_Open code in the workbooks being opened and (as I indicated above) no external links, references or function calls.

What's weird is that if I step through the procedure in the Command Debugger, everything works fine. Even weider, if I complete step-by-step processing on the first target file then I can press "Play" and the code will complete execution and process all the remaining files without error.

I have rebuilt/recreated/re-ordered the target files and even moved them to a different volume.

If anyone has seen this before, or has any idea what the cause may be, or even just a wild idea, I'd love to hear it.

Code segment attached.

*
'*** Process each file in the list provided
'*
For intCounter = 1 To intWBS_Files

Call Debug_Msg("Opening WBS File")

Application.EnableEvents = False
Set wbkThis_WkBk = Application.Workbooks.Open(strWBS_Files(intCounter), 0, False)
Application.EnableEvents = True

Call Debug_Msg(("Opened WBS File:" & Chr(13) & strWBS_Files(intCounter)))

If (wbkThis_WkBk Is Nothing) Then
Call Write_Error_Record("File Open Failed", strWBS_Files(intCounter))
Else
Code continues.....

View 6 Replies View Related

Confirm Prompt Before Macro Runs

Nov 20, 2006

I have a button. When pressed, it runs a macro. Instead, after pressing the button, I would like the user to confirm to run the macro and display some info about it. This is to make sure the user does not accidentally run the wrong macro (button). I just need a prompt box, with a line info, and the two choices YES and NO. If NO is selected, nothing happens. If YES is selected, macro continues.

View 6 Replies View Related

Show Userform While Macro Runs

Nov 29, 2006

I got a code that makes an animated userform popup (web browser in userform). that works smoothly. but, when I have that code before two more codes. The userform does show, but the animation does not. Until all the following two codes are finished running. The purpose was to have the animation running while the two codes are being processed.

Main Code: Code with 3 different codes.

Private Sub cmdAdd_Click()
Dim iRow As Long
If Sheets("LookupLists"). Range("N2").Value = "EXACT" Then
Application. ScreenUpdating = False
' Loading user form popup
Call ShowFrm
Call CopyEmplInfo
End If
Call MergeCells
End Sub

View 5 Replies View Related

Macro With Delete Row - No Longer Runs

Apr 6, 2007

This macro ran fine until I started using Offset on ranges to have them extend. The macro replaces "L" with blanks but does not go on to delete the rows. The name "Type" refers to =Offset(Mem05!$A$2,0,0, CountA(Mem05!$A$2:$A$270),10)

Relevant part of Macro
wb06.Activate
Application.Goto Reference:="Type"
Selection.Replace What:="L", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
On Error Resume Next

Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveSheet.UsedRange

Is it using Offset that could be causing this error?

View 6 Replies View Related

Disable Calculation While Macro Runs

Mar 7, 2008

I have a Worksheet_Calculate Macro running in my workbook. I'd like to disable it temporarily when running another macro because its causing excel to run sluggishly.

View 3 Replies View Related

Automatically Scroll Window As Macro Runs?

Jul 31, 2014

Just to see how calculations were working out, I was trying to get a macro to scroll down the window as it calculated data.

Sadly, ActiveWindow.SmallScroll Down:=2 was too fast and =1 was too slow!

That's the only command I know to get this to work.

demonstration of a different command. Any way to get the window to scroll automatically to the cell which has just had information inserted into it?

Here's the VBA:

Sub CustomerCategory()
Dim Rng As Range
Dim Dn As Range

[Code]....

View 2 Replies View Related

Macro Runs Fine In Debug But Not From ComboBox

Feb 24, 2009

I have a workbook that contains 9 worksheets. Four of the worksheets have the same row lables in column B and must always be the same. Three of the worksheets are fed from the 4th sheet so that the integrity of the lables is maintained.

The user can change the lable value to meet their needs and they can insert or delete rows (within limits) as they see fit.

The attached macro "Sub Delete_Row_All_Sheets()" works fine when I run it from Debug (F8).

However, when I run it from Forms.ComboBox the macro returns to the "y = Application.InputBox("Enter The Row Number You Wish To Delete", _" screen. If I select cancel, the results I anticipated occur but I don't want the user to have to assume this will happen.

Why does the macro return to this screen when executed from the ComboBox but not when executed from Debug?

View 14 Replies View Related

Macro Runs On Wrong Workbook On Close

Jul 29, 2009

I have a macro on a particular workbook that runs when the workbook closes.

This runs fine when I close the workbook itself. If I happen to have other workbooks open and then I close EXCEL rather than an individual workbook, my macro that runs on close always runs when it is not the active workbook.

To put it another way, say that my 'run on close' macro is workbook 1. I also have workbooks 2 and 3 open as well. If workbook 3 is the active workbook and I choose to close Excel (and thus close all three workbooks), my 'run on close' macro runs straight away and, worse still, will run it on workbook 3 (my active workbook).

How can I stop the macro running until it is the active workbook in the closing chain, so that it only runs on the correct workbook? (workbook 1 in my example)

View 9 Replies View Related

Splash Screen - How To Display While Macro Runs

Sep 27, 2011

I have a splash screen I want to display while a macro runs. I've created all the necessary code based on information from this site but have a question about where to actually put the code as all the example I've seen are based on workbook open events.

I tried placing my code

UserForm1.Show

with in the macro I waned the splash screen to be displayed during but that doesn't work. Well, it does, but not as I intended. The splash screen pops up for the specified duration as part of the macro stopping the macro, then closes and the rest of the macro finishes running.

Do i need to call the splash screen from a certain point in the macro I wish it to be displayed during? I dont want the macro to stop running while the splash screen is showing.

View 1 Replies View Related

Formula That Runs A Macro When Data Is Present

May 12, 2008

I work on csv files which are created everytime someone makes a change in certain parameters used by a robot, however when opening these in excel they are nonsensical.

This can be changed with a few macros etc. but my manager would like it to be a "press one button and it works" procedure.

So what im looking for is some sort of function that checks if there is any data in the next column of the spreadsheet and runs a macro in that case and only that case.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved