Automatically Call Macro Based On Changed Cell Address & Text

Apr 13, 2009

I have the following code pasted into the worksheet module which used to work fine but no longer does. I didn't touch the code, it just stopped working.



Private Sub WorkSheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$A$16"
Select Case Target
Case "Custom Color 1": Call CustomColorInput1
Case "Custom Color 2": Call CustomColorInput1
Case "Custom Color 3": Call CustomColorInput1
Case "Custom Color 4": Call CustomColorInput1
Case Else:
End Select
Case "$A$17"
Select Case Target
Case "Custom Color 1": Call CustomColorInput2
Case "Custom Color 2": Call CustomColorInput2
Case "Custom Color 3": Call CustomColorInput2
Case "Custom Color 4": Call CustomColorInput2
Case Else:
End Select
Case "$A$18"

CustomColorInput 1-6 are the same except they input data into different cells F16-F21.

When I attach any of the CustomColorInput macros to a button it works fine. When I try to call it from the worksheet module, the data input box pops up but the data doesn't get entered into the cell. When I try to step through the CustomColorInput macros using F8, the input box pops up, I enter data and press ok. Then I continue with F8 and the debugger jumps to a custom function that I entered (below), which is not called for and is in no way related to the code.


Function PullAfterLast(rCell As Range, strLast As String)
PullAfterLast = Mid(rCell, InStrRev(rCell, strLast) + 1, 256)
End Function

When I close VBA, the data that I typed into the data input box is in the correct cell.

So basically, I'm getting three different responses from the offending code depending on how I call it up. Can anyone tell me what's going on?

More generally, in this and previous occasions, I've had problems with macros that cease to work for no reason that is apparent to me. What are some things that would cause a macro to stop working, without actually changing the code (other than the obvious, like referring to names or worksheets etc. that don't exist anymore)?

View 9 Replies


ADVERTISEMENT

Automatically Calculate 2 Cells Based On Cell Changed

Apr 25, 2009

I have some rather complex formulas that when a value is placed in one of any three cells it solves for the other two, taking values from other places on a worksheet (including the cell itself).

Scenario: Cell F10, G10, and H10 all have formulas in them. If a value is placed in F10 it solves for G10 and H10. If a value is place in G10 it solves for F10 and H10. If a value is placed in H10, it solves for F10 and G10.

I really do not think the actual formulas matters at this time...

Has anyone done this before, using VBA code to place the formulas in cells F10 G10 and H10? Look for a working example of this if possible.

View 9 Replies View Related

Macro To Automatically Convert PrtScr Image Based Text To Real Text In Cell

Mar 22, 2014

Programming Excel VBA Macro to do OCR (text recognition) from a prt scr screen capture image and input the text into cells. Currently my Excel file has a push-button, and upon clicking on it the macro pastes into Excel the current clipboard image I have created by pressing prt scr while in another program. The macro then crops the image to the region with the applicable text. I have to then manually type the text I see in image format into the appropriate cells.

the VBA coding to automate this? I'd like it to use the clipboard image and run it through OneNote OCR, after which the applicable text values are automatically entered into the cells. Ideally the code will first crop to the region with the desired text before it does OCR. If this is not feasible, it will need to incorporate a method (keyword search?) to hone in on the desired text after the entire prt scr image has been OCRed.

View 8 Replies View Related

Return User Changed Cell Address

May 4, 2008

The format for the sheet is set in stone and can't change, and therefore my macro's operate on set columns / rows amd cells.

Because the sheet is huge, im trying to figure out a way to only run the macro's that need to run and more specfically on the changed location.

The Question

I need to create a routine that on the user changing a cell, it returns the cell position (row,column), then it will call a routine i have already which decides based on the cell location, which macro to run and where.

View 9 Replies View Related

Use Cell Address' To Call Up Sheet Name In A Formula

Oct 6, 2009

If I have 12 sheets in a workbook (Jan, Feb,etc..) can I have those names in specific cells (A1,B1,etc..) and call them out in a formula as the cell name as opposed to the actual name?

like A1!C4:C100
instead of Jan!C4:C100

View 2 Replies View Related

Call Macro Based On Selected Cell Value?

Dec 27, 2012

code to do the following:

If any cell in range T75:KH1000 is selected whose value is "Exit", call the macro named View6.

(There are about 40 non-contiguous cells in this range whose value is "Exit".)

View 2 Replies View Related

Run Macro Automatically Once 3 Cells Have Changed

May 21, 2008

how to alter this Private Sub for my code to execute automatically once all 3 cells have changed. At the moment it executes as soon as any of the 3 cells change.

Here's the Private and Public Sub codes:

View 9 Replies View Related

Automatically Updating Adjacent Cells Based On Dropdown List Selection Even If Changed

Apr 12, 2013

I have a workbook that has two worksheets. One worksheet is an input worksheet. A user will select a date from a drop-down list and type in the events that occurred on that date in 8 adjacent cells. The user selects a button that advances date and clears form. On sheet 2, whatever was typed into sheet one is saved via VLOOKUP formula. However, if I try to change something retroactively and select a previous date from the drop-down list, it clears everything in sheet 2 that was typed for any selected day.

View 1 Replies View Related

Automatically Calculate Cell When Changed

Oct 24, 2006

There is a column in my spreadsheet which needs to reflect a " percent done".
I used to enter just a numerical value in (eg. 20) to reflect 20% done. My boss wanted it to show as an actual percentage (eg. 20%). I changed the format to Percent, Zero decimal places. Then you had to enter .20 to get the 20% to show.
Now my boss doesn't like that - and wants to be able to enter "20" to get the 20% to show. I put the following code in my SelectionChange event...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'other logic
If Target.Column = Asc(PercentDoneColumn) - 64 Then
If Target.Value <> "" Then
Target.Value = Target.Value / 100
End If
End If
'end other logic
End Sub

My problem is that this works well when putting a new percentage in, but not for when you click on a cell that already has a percentage in it. For example, if you have .2 (displaying "20%" in the cell), and click on that cell, it divides that number by 100, and gives you 0.2%, displaying as "0%". I want to enter a number between 0 and 100, have it displayed and stored as a percent. At this point, I'd settle for the displayed, but would prefer to have it stored as a percent, too.
I also want it to not reset my value unless I'm putting a new value in!

View 4 Replies View Related

Automatically Save My Workbook When A Certian Cell Range Is Changed

Jul 21, 2009

I am very new to vba and trying to figure out an auto save macro that will automatically save my workbook when a certian cell range is changed. Right now I have a macro set that automactially record the time and date of when a change is made to the name cell, I want to set up a macro that will automatically save the file when the time is updated.

This program is used by several users and they have a tendnecy to forget to save the program so that when other people want to check the updated data nothing has changed because the changes have not been saved. I have attached the file that I am working on. When a change is made in column F then Column G automatically updates, now I want column G to trigger autosave. I would also like a msgbox to appear to tell user that file has been saved.

View 3 Replies View Related

Automatically Call Userform When Cell Is Selected

Apr 26, 2013

I have some Worksheet_SelectionChange code that automatically calls a Userform when a cell is selected.

What I want to do is retrieve the data from the cell where the Userform is called from and enter it into a textbox on the Userform.

There are 3 other columns to the right of the cell that is selected.

If there is data populated there, I want this to be copied to the appropriate textboxes on the Userform too.

View 1 Replies View Related

Automatically Add Username, Current Date And Time Each Tiime Any Cell Is Changed

Feb 27, 2009

I am looking to have a macro which will automatically add the username and date to a cell, when the cell above changes (or in this case =x). I have a bit of code from a previous project, but I have changed Target.Row to Target.Column and it is not behaving as I require:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("B2:BZ2"), Target) Is Nothing Then
Range("C" & Target.Column).Value = Format(Date, "dd-mmm") & " " & Format(Time, "hh:mm") & " by " & (Application.UserName)
End If
End Sub

See the attachment for the example. What I need is whenever row 3 ="x" I need the corresponding cell in row "d" to update with the latest date, time and username. Please not the macro is currently not active on the sheet as i've added the ' character.

View 3 Replies View Related

Call Macro From Text Value

Mar 13, 2012

I have a named range, which pulls a text value from a vlookup. This text is the name of a vba sub I have written. What I would like to do, is call the macro based on this value. This is what I have so far but I can't get it to run.

Code:

Sub ControlSheets()
ActiveSheet.Calculate

Hideallsheets
Dim MacroSub As String
MacroSub = sheets("Control").Range("SheetMacro").Value
Call MacroSub 'this is the name taken above that i want to call

End Sub

View 2 Replies View Related

Automatically Hide/Unhide Columns Based On Cell Text

Jan 10, 2009

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 13 Then Exit Sub
If InStr(Target.Value, "Other (specify in next column)") Then
Columns("N").Hidden = False
ElseIf WorksheetFunction. CountIf(Columns("M"), "Other (specify in next column)") = 0 Then
Columns("N").Hidden = True
End If
End Sub

but I have a lot of columns that I need to perform as above and I have put the code together as below

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next

If Target.Column = 13 And InStr(Target.Value, "Other (specify in next column)") Then
Columns("N").Hidden = False
ElseIf WorksheetFunction.CountIf(Columns("M"), "Other (specify in next column)") = 0 Then.................

Using the above code, when I selected more than one cell anywhere in my workbook and pressed delete I was bugging out with a runtime error 13 message. You can see from the above code that I inserted "On Error Resume Next" - this got rid of the runtime error 13 message, but now when I select more than one cell and press delete, hidden columns are incorrectly revealed in my worksheet. how I can extend the working code at the top of this posting so that it works for a number of different columns in my Worksheet i.e. without the runtime error 13 occurring and without columns being incorrectly revealed.

View 8 Replies View Related

Automatically Enter Text In Cell Based On Another Cell?

Jul 29, 2013

I am trying to enter a value in a cell which is dependent on a corresponding value in a table. I have a table A which has a cab type and a corresponding cab number.

What I want to achieve is that when I enter the cab number in another table say in cell (D3), the cab type is automatically entered in cell (C3).

Table A
Cab Type
Cab No

Indigo
100

Indigo
758

Innova
1544

Indica
1675

View 1 Replies View Related

Automatically Enter Text In Cell Based On Another Cell

Jul 28, 2013

I am trying to enter a value in a cell which is dependent on a corresponding value in a table. I have a table A which has a cab type and a corresponding cab number. What I want to achieve is that when I enter the cab number in another table say in cell (D3), the cab type is automatically entered in cell (C3).

Table A
Cab Type
Cab No

[Code].....

View 7 Replies View Related

Automatically Select Item From Dropdown List Based On Cell Text

Apr 8, 2013

I have a spreadsheet where user can search for information inside a search box and the appropriate rows are returned using formulas.

I have a drop down list (Category: Model) in the search box as well as a search field (Category: Program, cell D2). Underneath the search box, search rows are returned with column categories: Program, Model, etc.

What I require is that if a user enters the specific program into the search field D2, then the dropdown list would automatically choose which model that program belongs to based on the returned row.

For example, if I typed "engine" into D2 and pressed enter,

Under the records section (Row 14 and beyond), the following record will pop up:

Program
Model
Indicators

Engine
F-16
3a

Based on the record, F-16 would be chosen from the dropdown list. Is there any way this can be done?

View 6 Replies View Related

How Do I Get My Customer Address To Automatically Fill In (cell B)

Dec 11, 2006

i have a an invoice template setup on my computer in excel.

what i would like to know is how do i get my customer address to automatically fill in (cell b) if i select them by customer number (drop down menu in cell a) in an different cell (cell c)

View 9 Replies View Related

Call Macro Based On CheckBox State

Mar 12, 2008

I have a checkbox and a command button on my sheet. I want that, depending if the checkbox is marked or not, I can call two different macros. I don't know if this is possible at all or maybe can be done easier otheriwise, but this would more or less be my idea of what should happen:

Private Sub CommandButton1_Click ()
' If CheckBox1 = marked
Call MacroA

'Else (CheckBox1 = unmarked)
Call MacroB
' End If
End Sub

View 4 Replies View Related

Macro To Add Additional New Rows Based On Number In A Call?

Jun 3, 2014

create a macro that will insert a certain number of blank rows to my spread sheet. The number of rows is determined by the #of tasks calculated for that day and is in column B. For example if in column A the date is 01-07-14 and in column B it has 7, I would like 7 rows inserted with the date in column A to remain the same in all 7 rows. Ideally I would like to use this macro for every row, so if the next row down has 02-07-14 and 6, I would like it to add 6 new rows with the same date.

I have attached a copy of the spread sheet for reference.

View 4 Replies View Related

Show A Message When Cell Text Is Changed

May 16, 2006

In a range of cells (e.g. B26-B40) I have names (first name and second name or first initial and second name). This data is carried from sheet 1 to the second sheet via formula. Some cells may be blank as well.

A VB code to display a message when the user changes the name in any of these cells with data or adds a new name to a cell that is blank, in sheet2

View 3 Replies View Related

Command Button To Call Macro Based On Selections In Two Combo Boxes

Aug 21, 2006

I have two combo boxes that both contain 7-12 separate search criteria for the user to choose from. The other includes months and the other value ranges in text form. Based on the selections, e.g. "August" from other and "increased by more than 5 %" from other, I'd like to have a command button to execute the appropriate macro. I've already compiled the macros for each occasion but I just can't figure out how to get the button to execute them. Can I use the Select Case statements? If so, how?

Oh, and whether it's relevant or not, the boxes and the button are from the control toolbar.

View 5 Replies View Related

Automatically Fill In Column When Certain Cell In Column Changed

Jun 18, 2009

I am trying to have some automation to my WS and what I want to do, is if a certain column (column 104) is changed, it will fill out that column with the data entered as long as the account is the same (column 5). Here is the code I tried, but realized very quickly, it puts me into a loop. This is being called by a change worksheet fuction

If Target.Column = 104 Then
If IsEmpty(Target) Then
Else
testacct = Cells(Target.Row, 5)
temptest = testacct
s_TempSwitch = Target.Value
Testoffset = 0
Do While temptest = testacct
temptest = Cells(Target.Row + Testoffset, 5)
Cells(Target.Row + Testoffset, 104).Value = s_TempSwitch
Testoffset = Testoffset + 1
Loop
End If
End If

View 3 Replies View Related

When Cell Date Is Changed Then Macro Should Run

Jun 25, 2014

The following code works fine but now I want it to work without a userform. SO there is no userform and so no controls.

When the user changes date in a cell then a macro should run and following kind of code should execute.

[Code] .......

View 3 Replies View Related

Call Macro When Clicking In Specific Cell From Personal Macro Workbook

Aug 13, 2014

This is the code I use to call a macro when the macro Im calling is in the same workbook.

[Code].....

However, I would like to call this same macro when using another workbook. I copied the macro "Clearformating" and pasted into a personal macro workbook module. However when I add this code to the sheet tab it will not run the macro.

I also tried this code.

[Code] .....

View 2 Replies View Related

Running A Macro When A Value Is Reached In A Specific Cell Used To Call Up Macro

Jan 7, 2009

I have a Sheet sheet1 and I want to run a macro when the cell D2 in Sheet1 is equal to 10,7,5,and 3. I only want this macro to run when those values are reached the macro then puts the data onto a sheet called wps. The macro is run as a module and is a sub macro.

View 9 Replies View Related

Automatically Run Udf When Color Is Changed

May 2, 2007

I have a UDF that goes like this:

Function SumIfPurple(inputRange As Range, _
answerRange1 As Range, _
answerRange2 As Range) As Variant
Dim SumAnswer As Variant

'If inputRange is turned purple then it is equal to anserRange1, if it is left with no fill it is equal to answerrange2.

If inputRange.Interior.ColorIndex = 39 Then
SumAnswer = answerRange1.Value
Else
SumAnswer = answerRange2.Value
End If
SumIfPurple = SumAnswer
End Function

I would like to have a sub that will have the formula automatically calculate when the inputRange's color is changed.

View 6 Replies View Related

Vlookup Changed Validated Cell Value In Macro

Jul 2, 2009

I have a worksheet containing a cell (say A1) that has a validated list of times (data/validation/list) where the cells in the list contain times in 8 minute increments. The user can select cell A1 and manually select any of the validated times from the list. A vlookup formula on this worksheet uses the content of cell A1 to look for this time in another section of the worksheet. When the time is selected manually, the vlookup formula works properly.

As part of a macro, the macro will change the time in cell A1. I do this in the macro by selecting and copying the desired time from the validation list and pasting it into A1. Cell A1 does change to the new value, however the vlookup formula that uses A1 shows a result of #N/A. If I manually change the time, it again works. I am looking for a way to have the macro change this cell to another time and for the vlookup formula to work as it should.

View 2 Replies View Related

Macro To Change Sheet Name When Cell Value Is Changed?

Jun 21, 2012

I would like to create a macro that will automatically change the name of the sheet any time a value is entered into cell a1. For example, in cell A1 of sheet1 I would input "Hello", and then the tab for sheet1 would be automatically renamed to "Hello".

Here's the twist - the workbook will have multiple sheets, and I want all tabs to reflect the value of a specific cell (a1) in each sheet.

For example:

value in sheet1, cell a1 = "Yes" - corresponding tab name would change to "Yes"
value in sheet2, cell a1 = "No" - corresponding tab name would change to "No"
value in sheet3, cell a1 = "Maybe" - corresponding tab name would change to "Maybe"
etc...

The "tab change" cell would always be cell a1 in each sheet.

View 2 Replies View Related

Macro / VBA To Copy And Paste If Cell Is Changed?

Dec 18, 2013

- A database sheet called 'QAEQUIP' which contains information on the movements of pieces of equipment. This information in in order of Column A which is a movements reference number.

- A reporting sheet called 'Email sheet', which you put in a month and year and using macros it copy and pastes the relevant rows from the database and puts them in date order (e.g. put in October 2013 and it will show all of the equipment moves that happened in October 2013, and in date order).

What my end user would like, is to be able to add text to an extra column on the reporting page which gets fed into the database on the corresponding row. What would the best way to do this be? I was thinking VBA for each row (there aren't that many rows) that says if this cell is changed, copy and paste the cell into the corresponding row / column on 'QAEQUIP'.

View 4 Replies View Related







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