Run A Macro Based On Value Input In A Cell
I am using data validation to restrict the number of Characters a user can input in a range of cells. The number of characters in this however can vary based on which selection they selected in a different cell.
To put this as an example, if the user selects "hello" in cell a1, the data validation would allow 10 letters in the cell range c1:c20. If the person selects "goodbye" in cell a1, then the validation would only allow 7 characters in cell range c1:c20. I have been using the worksheet Change function, however it updates the validation regardless of what cell is changed.
View Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Run Macro Based On Cell Change
I am working on a training scheduler. In which a sheet contains the details of the trainings that are scheduled now i need that if any training is canceled then a mail needs to be sent (Status is updated in cell). I have code to send mail however the problem that i am facing is that how can i execute this macro when training is canceled. I did a search and found the following thread How to call a macro based on a value of cell? but the code given in the thread uses a specified cell address to execute the macro. Where as in my case I can not provide a specific cell address as any training can be canceled.
View Replies!
View Related
Run Macro Based On Cell Content
I have a drop down list made from the Forms toolbar with a list of items: 1, 2, 3, 4, 5. I have set it with a linked cell, so when you choose, say 3, from the dropdown, 3 appears in B10. I was hoping to add a 'Go' button, which would run another macro depending on what is in B10, i.e. so if 3 was chosen, then you press 'Go', Macro3 would be run. So I have 5 macros called Macro1 - Macro5, and I need some code for the 'Go' button which will run the right macro depending on what number is in cell B10.
View Replies!
View Related
Run Macro Based On Time In Cell Every X Minutes
1st post. Very basic understanding of Excel / Macros / VBA but I have searched and still not quite able to get what I'm looking for. I would like to be able to manually put in a TIME in a cell, and have a macro run at set times before that TIME e.g. something like If TIME in cell A1 =(hh:mm minus 30mins) run macro 1, If TIME in cell A1 =(hh:mm minus 5mins) run macro 2 It was suggested to me to use vba code that would constantly check the time against the system time and as soon as it is 30 mins before the time in cell A1 and the 30 mins flag in cell B1 was ‘N’ then it would run macro 1 code and set the 30 mins flag to ‘Y’ to show that macro 1 had been run. and that this could also do the same for the 5 mins event
View Replies!
View Related
Run Macro Based On Corresponding Cell Values In Range
I have a range "RangeOne" and i want to check the range row by row. In each row I want to check for value in second cell. If the value is 10 or more then the entire row in the range should be selected and then execute a macro. If the value is 0 to 10(but not 10 exactly) then the row in the range should be selected and then execute macro2.
View Replies!
View Related
Run Macro Based On Value
I am trying to write a procedure that takes the value of one combo box ( a string) and based on that value compare a range of values to populate a cell with a tax bracket. So if the value is say "Single" it will then go look and see if income is between 0 and 7825 or 7825 and 31850 etc to populate a cell on the worksheet with the appropriate tax bracket. I then need to do the same if the combo box value is married, filing jointly, etc.
View Replies!
View Related
Change Result Cell Format Based On Input Cell Value
Macro Based on an input cell’s (e.g. B12) setting of “yes” or “no”, format several other cells (e.g. B20:G20, B23:F23, C26:J26) as follows: keep the existing yellow shading if input cell is “yes”, change to grey shading if input cell is “no”. I would like this macro to run automatically whenever the input cell value is changed.
View Replies!
View Related
Formula For Cell Result Based On Other Cell Input
I'm trying to work out the way of having a cell give a result based on what has been input into two other cells. Basically I'm doing up a risk management spreadsheet. I need to have in one cell the LIKELIHOOD of an incident, in the second cell, the CONSEQUENCES of it happening and ending up with a RISK MANAGEMENT ASSESSMENT in the third cell.
View Replies!
View Related
Cell Values Based On Input Of Another Cell And Sheet
I want to tie the values of some cells on Sheet 2 to what's put in into corresponding cells on Sheet 1. Example If Cell B3 on Sheet 1 has the string "B off" put in, Sheet 2 should automatically get "R1" in cell B12, "B off" in cell C12 and "ID123456" in cell D12. If cell B3 on Sheet 1 is empty, B12:D12 should be blank.
View Replies!
View Related
Restrict Cell Input Based On Text Of Another Cell
I have two coloumns on a worksheet. In the first column I have data validation drop down list. I want to be able to: if the first column "Other" is chosen then the next cell will allow text for description, if anything other is chosen in the first drop down list cell then I want the next ( text for descritption ) cell to be resticted.
View Replies!
View Related
Highlight Part Of Cell Based On Input
I want to track winning football teams by highlighting the victor. So lets say I have a cell that contains Raiders @ Niners and another cell containing "home" or "away" indicating the winner. Based on the home/away cell, I want to either highlight Niners/Raiders.
View Replies!
View Related
Run Macro Based On ComboBox Selection
can i use a combo box with a dropbuttonclick to run the macro only when the arrow is selected . The problem I am having is the macro will run on the selection of the arrow which is whatt I want but it also run when I make a selection it the combo box
View Replies!
View Related
Run Macro Based On Values In Column
I am trying to write code that will run a macro based on values in a certain column. I do not know how many rows are present at the time the macro will be run. For example, if Column A has the number 2 in every row then I want macro Z to run. However, if the values are not the same then I want macro Y to run.
View Replies!
View Related
Hiding / Unhiding Rows Based On Cell Input
I am trying to work out a macro to hide and unhide rows in worksheet 6 based on a cell input (cell I6) in worksheet 1 based on the following: >> If I6 in Worksheet 1 = 1 or 5 or 6 then Hide Rows 19 to 24 in Worksheet 6 >> If I6 in Worksheet 1 = 2 then Hide Rows 21 to 24 in Worksheet 6 >> If I6 in Worksheet 1 = 3 or 4 or 7 then Hide Rows 17 to 20 in Worksheet 6 >> If I6 in Worksheet 1 = 8 or 9 then Hide Rows 17 to 20 and Rows 23 to 24 in Worksheet 6
View Replies!
View Related
Protect Or Unprotect Cells Based On Cell Input
I am working on my spreadsheet and was wondering if anyone knows if cells can be Protected or Unprotected based on the value of another cell? Here is what I am looking for: If cell "A16" on the "Input Sheet" equals AR then Protect Cells J16, K16, L16, M16, N16, and O16 If the value of A16 on the Input Sheet DOES NOT equal AR then leave those cells unprotected. Has anyone ever done anything like this? On my spreadsheet it would allow the user to skip the unnecessary cells as opposed to having to Tab through them. Not a big deal but definitely would be a time saver and a lot more user friendly. If you have any questions or concerns just let me know. I will wait to see what the Excel Guru's come up with.
View Replies!
View Related
Macro To Run Serial# 1 To 10 Based On Relative Reference
I need a macro that can run a serial# 1 t0 10 (or more or less) with A1 being starting point. Here is my illustration data. Coloumn:A Coloumn:B 1 IrfanAneeza 2 Scooby Dooby Do 3 Dooby Dooby Do 4 Yaba Daba Doo However, there is a little kicker in it. The range of coloum:B varies all the time i.e. B:B could be 1 to 10, it could be 1 to 3 etc. Thus, macro should list serial#'s based on the coloumn B:B range of data.
View Replies!
View Related
Run Macro Based On Validation List Choice
I'm looking for a method, vba macro or Excel code, to preform the following task: In the C column the user chooses one of several options from a menu, let's call these options 1 - 10 (this part is already done). Depending on the choise, different things are supposed to happen: For 1-9, the formulas for cell A - Q on the current row should be copied to the next row (but with +1 in row number in formulas of course). For 10, 3 blank rows should be created (well they already are blank..), on the forth row down, A3 - Q3 should be copied exactly. On the fifth row, the same formulas thing that was created for choise 1-9 should be created. Since the real xls-file is too big already and it contains some sensitive information, I can't attach it here, but I made a small and similar xls-file, that better explain what I want to do.
View Replies!
View Related
Run Macro Based On SUM Function Result
i have the formula "= sum(A1:A10)" in cell A4 & would like to call macro when the value changes. The code i'm using below work's if I manually type in a value, but isn't working with the formula. Private Sub Worksheet_Change(ByVal Target As Range) ' Checks for cell value change If Intersect(Target, Range("A4")) Is Nothing Then Exit Sub ' If cell value change, calls msgbox based on criteria Else If Range("E4").Value = "C" And Range("A4").Value > "30" Then Call MsgBox1 End If If Range("E4").Value = "F" And Range("A4").Value > "38" Then Call MsgBox2 End If End If End Sub
View Replies!
View Related
Conditional Input In A Cell Based On Data In Two Different Cells And Other Values
I have lot of data in three columns like this. The first column is "Name", the second is "Comment" wherein I want the macro to write some comment, the third one is DOB. The problem is that the names in column 1 repeats many times. I want a macro to write in column B "either Old or Older or Oldest" based on the Name and DOB. Thus David with DOB 13 Sep 1982 be marked Oldest in Column B and David with DOB 25 Aug 1988 be marked Older and David with DOB 24 May 1990 be marked Old. Similarly William and Rita should be marked either old or older or oldest. As the data are enormous I do not want to refer the actual name in the programming. I want to call them using a variable in programming. NameComment DOB David 25 August 1988 David 13 September 1982 David 24 May 1990 William 24 March 1980 William 25 July 1987 William 13 August 1989 Rita 17 July 1990 Rita 24 April 1989 Rita 13 June 1988 The example file is attached
View Replies!
View Related
Run Macro Procedure Based On Drop-Down Item Selected
I am trying to accomplish is to display a dropdown or combobox with a list of choices. I want the backcolor to be shaded light green to match instructional text that appears in the cell above. That I have working with the selections appearing. Once a choice is made I want a separate procedure to run that will somehow know which choice was made. I can't put the code within the module for this particular sheet as it is dynamically recreated each time the data is refreshed and the code will disappear. This may seem to be an odd practice but this is how 25+ workbooks are coded within this system for my employer's customer and it is a required practice.
View Replies!
View Related
Run GoalSeek Based On Cell Value
I'm trying to make a macro that will allow me to run multiple Goalseek in the click of a button. This I've been able to do but now I've included one more tweaking which is that I want the variable to change depending on the "method" (ie EBITDA or FMV). Yet I get an error message on the goalseek formula and I don't know what to do and how to solve it. See below for the "macro" Sub Target_IRR() If Range("C73") = "EBITDA" Then For i = 94 To 96 Cells(i, 3).GoalSeek Goal:=Range("F93"), ChangingCell:=Cells(i, 4) If Cells(i, 4) < 1 Then Cells(i, 4) = 1 Next i ElseIf Range("C73") = "FMV" Then For j = 94 To 96 Cells(j, 3).GoalSeek Goal:=Range("F93"), ChangingCell:=Cells(j, 5) If Cells(j, 5) < 1 Then Cells(j, 5) = 1 Next j Else: MsgBox ("No Variable") End If End Sub
View Replies!
View Related
Run Macros Based Cell Value
I am trying to create a macro based on value in a cell. For example if J2 is greater than 1 then run macro A. The code I have is: If j2 > 1 then Call MacroA The file imported as a text tab deliminated file and I believe that even though J2 might be 10.05, it does show up in the formula bar as just 10.05 not =10.05. I don't if this makes a difference. The J2 cell could either bland or values ranging from 1 to 100. If it is blank I want to run a different macro.
View Replies!
View Related
Open A Workbook And Run 1 Of 4 Macros Based On 3 Cell Values
I'd like to automatically run 1 of 4 macros depending on some criteria. Every workbook created has, unfortunately, the same worksheet name, so that leaves the only differences between the 4 possible loaded workbooks in the cells area and even those can be similiar in many ways. But....I found some criteria to separate all 4 workbooks...Here they are... run macro 1 if this 1. Worksheet name says "Screen" 2. Cell H1 has the word "Lead" run macro 2 if this 1. Worksheet name says "Screen" 2. Cell B1 has the word "records" somewhere in the cell 3. Cell H1 has the word "Lead" run macro 3 if this 1. Worksheet name says "Screen" 2. Cell B1 has the word "records" somewhere in the cell 3. Cell N2 has the word "Delivered" run macro 4 if this 1. Worksheet name says "Screen" 2. Cell B1 has the word "records" somewhere in the cell 3. Cell N2 has the word "Bevel" I don't know if this can be done, but if so, that would be fantastic! I'm thinking that the macro would have to be "global" and in the user's personal workbook?
View Replies!
View Related
Run Macro On Double Cell Click If Cell Part Of Named Range
I have a sheet where i have many differently named areas (like state1_1 and state1_2) When I doubleclick on a cell then a macro should run with following criteria: 1) Macro will run if the doubleclicked cell is part of any range in the list. Here I mean that names of ranges which belong to that list start with word state (like state1_1 and state1_2). No other ranges should not be in that list. If the cell is not in the range that is part of the list, then nothing should happen.
View Replies!
View Related
Pass Each Cell Value In Range To Cell & Run Macro Code
I have workbook template that I use to generate reports from a list of depts. This list is contained in a drop down cell that is a named range in a different worksheet. My current process is as follows: -Select Dept Name from the list -Click a command button which is assigned to code that calculates and saves to a file -Repeat for next report until all reports are generated I would like to automate this process by producing all reports with a single command with the following functionality: -The Dept Name needs to be populated in the specified cell containing the current drop down because it drive various vlookups and other formulas -If possible, I would like to retain the drop down functionality as I would like to have the option of running an individual report or running the “batch”.
View Replies!
View Related
Check User Input To Prevent Run-Time Error
what I want. It relies on an input box asking the user to enter a part code, which when found creates a duplicate copy. However, if the user enters a part that doesn't exist I get a run-time error. Can anybody point me in the right direction so when a user enters an incorrect part they get a message telling them it doesn't exist. Private Sub SortTest_Click() Dim s As String Dim r As Excel. Range Range("A2").Activate s = InputBox("Enter the number you wish to find") If StrPtr(s) = 0 Then MsgBox "You must enter an existing part number!" Else Set r = Cells.Find(What:=s, After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) Range(Cells(r.Row, "A"), Cells(r.Row, "AH")).Copy Sheets("APL").Cells(r.Row, "A").Insert Shift:=xlDown Application.CutCopyMode = False Application.Goto Sheets("APL").Cells(r.Row, "H") Selection.Offset(-1, -5).ClearContents Selection.Offset(-1, 0).Select End If End Sub
View Replies!
View Related
Run Macro If Cell Value Greater Than 1
I would like the macro to run on its own if the cell value is greater than 1 i have data comming into the excel sheet using sql, and j1005 cell calculates the entire data displays 1 if condition of j1005 is met else display 0 . the data refreshes on its own and j1005 keeps check every time and display the value 1 or 0
View Replies!
View Related
Run Macro When Cell Selected
I've seen plenty of code for running a macro when various events occur, but how do I run a macro when a cell is simply selected? I have a calendar Macro, and there are two cells that need date input. I want the user to select the cell, and the calendar to pop up. Macro for the calendar works correctly, just need the code for the activation upon cell selection.
View Replies!
View Related
Run A Macro By Clicking A Cell
I would like to run a macro by clicking a cell. I don't want a toolbar button/menu item and Hyperlinks don't work. Can this be done? More info: My macro selects the current row in Sheet A and moves it (cut & Paste) to Sheet B in the workbook. The macro then goes back to Sheet A and deletes the now blank row.
View Replies!
View Related
Macro To Run When A Cell Changes On Different Sheet
I am tring to write a macro that will hide certain columns on sheet2 based on the value of cell a1 of sheet1. I have been able to get it to work when the input cell is in the same sheet. What I need for example is if someone enters 1 into cell a1 on sheet1 then on sheet2 the macro will hide column c to f. If they then enter 2 into cell a1 of sheet1 then sheet2 will unhide column c to f and hide column g to J.
View Replies!
View Related
Run Macro When Cell Is Selected
I just want to run a macro when a certain cell is selected. upon investigation, i have found that I can right click on the sheet tab and view the code. I can then add the following Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$a$1" Then run(macro1) end if End Sub
View Replies!
View Related
Cell Value To Run A Specific Macro
I have several macros that email a specific section of a workbook when I run it - I have an icon (image) per section. I want to be able to run a macro that calls one of these section specific macros based on a choice from a drop down list. It would work this way: - From the drop down in cell E11 I choose "New Jersey" - I would then click on the email image next to the cell (next to E11) - that macro would call the macro that emails the "new Jersey" section. I realize there might be a much better way, easier even. However, I already have the other macros written out and would just want to add this step.
View Replies!
View Related
Run Macro On Cell Click
i have macro that opens up a calendar and inserts a date. i'd like it to automatically run when a particular cell is clicked. i don't want it to run for all cells, just cells in a certain column.
View Replies!
View Related
Run A Macro On Cell Click
i have this piece of Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) If Target.Range.Address "$A$1" Then macro1 Exit Sub End Sub I want so when i click on cell A1 it will run macro1. So far the click on the cell works, but it works with every single cell I click on. How to I get it to just work with cell A1 instead of everyone single cell I click on? Also, there are about 30 different cells that will run different macros, how would I go about creating adding the code the one above without having to create separate sub worksheets?
View Replies!
View Related
Run A Macro When A Cell <> Blank
I have a macro that runs when the user clicks on a button. I want it to run when a particular cell has data in it - after the user selects an item from a drop down. How can I make the macro trigger based on a cell being non-blank?
View Replies!
View Related
Only Run Macro When Cell Value Is Empty
I would like to have an alert msg to prompt the user whether he/she wan to proceed to run the macro upon the macro button is pressed. However the alert msg will only pop up if cell value, A1 is not empty. In the alert msg, The user will have an option to choose to run the macro and do not run the macro. Another question. I have a macro copy some data from other workbooks. I would like to alway return to a worksheet, named"Summary" after the macro is run. any way to do that ?
View Replies!
View Related
|