Run Macros Based Cell Value

Dec 12, 2007

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 2 Replies


ADVERTISEMENT

Open A Workbook And Run 1 Of 4 Macros Based On 3 Cell Values

Jul 30, 2009

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 12 Replies View Related

Setting Macros - Possible To Put Image In Comment Based On Value In Cell

Nov 12, 2012

Is it possible to put image in comment base on the value in cell ?

For example

c1 c2 c3
R1 A
R2 B
R3 C

I can put A.jpg to C1R1"A", B.jpg to C2R2 "B", and C.jpg to C3R3

Or irregular arrangement ??

View 9 Replies View Related

Macros To Save Worksheet Based On Cell Reference

Feb 12, 2009

I have a macros ( code inserted ) as you can see in my code the macros save the workbook in any file name you chose just by changing the any filename option.

I would like this to be changed so that it saves based on a cell reference, say i has a name in lets say B10 i would like it to save as the name in B10.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
Dim bk1 As Workbook
Dim bk As Workbook
Dim myfilename As String

View 9 Replies View Related

Run Macros Automatically Based On Drop-Down Value

Aug 30, 2007

I have this simple code which runs a macro from a dropdown list.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
If Target = "RunMacro1" Then
Macro1
End If

End If
End Sub

Im trying to add this second dropdown list.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
If Target = "RunMacro2" Then
Macro2
End If

End If
End Sub

Can't seem to add a second Worksheet_Change event, nor include the second code within my first.

View 2 Replies View Related

Enable Different Macros Based On Combo Box Selection

Mar 10, 2009

I have a spreadsheet with 2 combo boxes - Combobox 1 enables a user to specify if they want to look at the data on the sheet by week or month - it has just 2 options - "select by week" or "select by month"

The list in combobox 2 changes based on the selection in combobox1 - so if you select "select by week" , a date list by week shows up.

Combobox 2 is supposed to run a macro which updates some backend pivot tables. there are 2 types of backend pivottable - weekly tables and monthly tables.

What i am not sure about is how to get the selections in combobox 2 to run either the weekly macro or the monthly macro based on if combobox1 is set to week or month ...?

View 9 Replies View Related

Automatic Response Based On Grouping Criteria Via Macros

Mar 27, 2014

Essentially what I want, is to type a medication in, lets say, A2, and for a macro to produce a response in B2 based off of grouping criteria from another worksheet. My workbook better explains what I would like to see happen. A macro would be best for this, right?

View 7 Replies View Related

Creating New Sheets With Macros Based On Column Information

May 9, 2012

I am new to using Macros and have not had great progress building a macros to make my life easier.

What I am trying to do
-In my main database tab 'FW Telecom' Use column A ( a set of numbers) to create a new tab based on that number, with a 'FW' infront IE ( column A shows 11, i want the tab to read FW 11)
-I want to create one for every number in the column
-Then I would like to copy my 'Template' tab to each new tab.
-From there I would like to fill in the information in the new tabs from the main database tab 'FW telecom'
-Since they will all be copies of the original template, i figure i can just get it to pull from the first column A and then fill in the info.

Not too much in theory going on here, just take my database and move the pertinent information to a user friendly look which I set up in 'template'

View 6 Replies View Related

Run Individual Macros Based On Validation List Selection

May 7, 2008

I have been searching through the site trying to find a solution to my issue, but I just can't seen to fixt it. Here is the scenario. I am working on a spreadsheet that will read some data, use that data to update the main chart and fill in the information in a table next to that chart. I recoreded 22 macros, total. Each macro corresponds to the especific type of chart that I need/want.

I want to be able to click on a drop down menu above the chart which will have each of the 22 options. Once the user clicks on the desired option, the specific macro will run and do that it should do. When I run the individual macro (without the VB that I wrote and will mention below), the system does what it should do. Everything looks dandy. But then I added this VB code to the sheet where the chart is:

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Range("A12").Value
Case "1"
Call a
Case "2"
Call b
Case "3"
Call cc
Case "4"
Call d
Case "5"
Call e................

View 2 Replies View Related

Using Macros To Delete Cells And Rows Based On Specific Criteria?

May 7, 2012

Each week I run a report that produces over 2,000 rows. I have to manually go through and delete things, by the time I am done, there may only be 320 rows left. I would apply a recorded macro, but the report is not consistent each week. There may be more or fewer rows depending on the week.

I would like to be able to run a macro that looks in column B for a specific value and if it contains that specific value, I would like the cells to the right of it to have their contents cleared.

Next, in column C, I have...

Employee2's Name
Employee2's Number
SPACE

[Code]....

I would like to be able to delete the rows, starting from Employee 2 to just before the second SUB TOTAL.

So, all I would have left in column C is

SUB TOTAL
SPACE

View 9 Replies View Related

Encourage Enabling Of Macros: Disable Macros When Opening Then The Worksheet Menu Bar And Other Command Bars Are Still Available

Aug 26, 2009

I have an Excel 2003 program that contains macros. One of the macros hides certain command bars and disables the worksheet menu bar. On close the opposite is true. The problem is, if a user uses the disable macros when opening then the worksheet menu bar and other command bars are still available. I would like to hide all of the data sheets and display another sheet that would normally be hidden displaying a message that the macros have to be enabled for the program to work correctly if disable macros is chosen. When the enable macros are used I would like the Error page to be hidden.

View 6 Replies View Related

Enable/Disable Macros When No Macros Are Present

Jul 28, 2008

I have a user that keeps a maintenance log in an Excel worksheet and sends an updated copy once a week to a board member. Two weeks ago, the board member started complaining that he was prompted to enable/disable macros on opening and became worried when my user stated that no macros were used in the book. He is now concerned that we have sent him a virus.

I know the file is clean because I've scanned it, and when I look at the file in VB, there are no modules or classes present just the Sheets 1-3 and the ThisWorkbook file. None of these objects have any code in them. My user does have some macros in PERSONAL.XLS but they are not used in the workbook in question.

No one else gets the prompt for enabling/disabling macros. Even if I set my security to prompt for any macros, I get no message. I'm convinced that there must be some setting in his Excel that is causing this individual to get this message. Is there anything else other than a macro that would cause this?

View 9 Replies View Related

Macros - Average Every 5th Cell?

Jul 29, 2009

I have an excel sheet with time in column A and scientific data in column B. I would like to get a macro that averages every 5 values/cells.

View 9 Replies View Related

Macros - Average Every 5th Cell

Jul 30, 2009

I have an excel sheet with time in column A and scientific data in column B. I would like to get a macro that averages every 5 values/cells.

View 9 Replies View Related

Cell Value To Fire Macros

Oct 24, 2006

I wish to fire one of 2 different macros, depending on the Target.Text value.
If the Target cell (in a named range) is blank then one macro fires, If the cell has text then another macro fires.

this is what I have

If Target.Column = 7 And Target.Row > 7 And Target.Text <> "" Then ViewPicture Target
Else
If Not Target.Column = 7 And Target.Row > 7 And Target.Text <> "" Then GetPicture Target
End If

I can only get the first if statement to fire, I get an "ELSE IF" compile error on the second "IF"statement.

It is nested in the

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Page
and I would like to get it to work with Named Range's, but not enough understanding yet.

View 9 Replies View Related

How To Delete Another WorkBook Macros Using Macros

Jul 23, 2005

What is the commands or script for deleting a macro automatically using
another workbook macro.

View 9 Replies View Related

Hiding Macros From The Run Macros List

Jul 14, 2008

Is there a way to hide a macro from the list where you choose which to run, but not in the VBA editor? The userbox I just created calls upon 2 different macros, and has a macro to bring up the userbox. I need a way to hide the macros in Module3 from selection, but keep the macros in Module4 available to choose to run.

View 9 Replies View Related

Macros In A Cell Function: Comparing 1 Value Against Another

Apr 29, 2006

Can I run a macro from a cell function in Excel 2003 with the idea of
comparing 1 value against another and if its true, it gets highlighted yellow?

View 14 Replies View Related

Absolute Cell References With Macros

Jul 31, 2006

can't seem to understand how to keep cells absolute when creating a macro

View 8 Replies View Related

Pass Cell Variable Between Macros

Jun 11, 2007

I have a macro that nicely select the named range that the active cell is in. I want to chain on to that macro a macro that has a parameter a range with that active selection. I dont see how to "take" the active selection on the worksheet from within the macro and pass it to another. I assume I could change the cellInRange macro to return a range, however I dont yet see how to do that.

View 2 Replies View Related

Macros Causing: Too Many Cell Formats

Jul 26, 2007

I have got several different workbooks that I use that contain macros that format cells. However, just recently I have had countless problems with the macros telling Excel to format certain cells. There seems to be no logic or order to this. Also, if I then try to format the cells by hand, I get the following error message: "Too many cell formats"

View 3 Replies View Related

Combine Two Macros And Run Them On Double Clicking A Cell

Mar 20, 2009

I have two pieces of code. The first one puts a tick mark in the cell when you double click it. The second one hides column B of another sheet if the value in cell A1 of Sheet1 is "a". I want to combine these two codes so that when I double click cell A1 of sheet1 it puts a tick mark in the cell and hides column B of Sheet2 and clears the contents of range B2:B50 of Sheet2.

View 4 Replies View Related

Save File By Cell Entry And Keep Macros

Apr 2, 2009

would like to save a spreadsheet with the contents of a cell as the name. My problem is that I have several macros in the workbook and if I change the name of the file when I save, it won't run the macros when I reopen because the filename has changed. It presents me with an error saying it can't find the macro.

View 9 Replies View Related

Call/Run Macros/Procedures Where Part Name In Cell

Oct 9, 2006

I have a value in a cell named subNo. whatever that value is I want that routine to be called. How do I concatenate Sub & the number?

Sub WhichSub()
Dim varSubNo As Integer
Dim mysub As String
varSubNo = Sheets("Main").Range("subNo").Value
Call Sub & varsubNo 'how do I concatenate this?
End Sub

View 5 Replies View Related

Increase Cell By 1 If Another Cell Changes A Value Using Macros

Dec 8, 2013

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Address(False, False) = "C2" Then Range("F2").Value = Range("F2").Value + 1
End Sub

I am using the follow macros code when I right click my spreadsheet and enter it in the window there. My intention is to increase the value in F2 every time the value in C2 changes to a specific text value. For instance, if C2 has the value "Alex" I want F2 to increase by 1 every time C2 changes to say "Joe" and only Joe. If it changes from Joe back to Alex that does not need to be counted, only changing it to Joe needs to increase the value in F2 by one each time.I also need to do this for all values in the spreadsheet from C2-C59 and increasing the corresponding cell in F2-F59.

View 6 Replies View Related

Create Button In Excel With Macros Or VBA Code In A Specific Cell Targets?

Jul 9, 2014

I have created a individual tracker spread sheet in each user system and on the spread sheet I have inserted 2 buttons in 1st sheet. when employee wants to take a break he has to click on the log out button and when he came back he needs to click on login button. I have another sheet named "timings" and I have created 2 columns, one is login and another is logout. What I need is when user click on the login button, the system time and date to be auto update under login column and when he clicks on logout button the system time and date to be auto update under logout column.

View 14 Replies View Related

Create Macros To Print Area With Data Using Different Cell Format To Fit In One Page?

Feb 6, 2014

I have a calculator and I am trying to set a macro that will take the cells highlighted copy them to another sheet, change the format to standard( no background color) make the data fit in one page and print it.

this is what I got so far:

Sub Set_Print()
'
' Set_Print Macro
' set printing area and print

[Code]......

View 3 Replies View Related

Keyword Search - Macros To Change Font Color For Specific Keywords (not Entire Cell)

May 5, 2014

I need to conduct keyword searches in excel and color the keywords a different color without changing the font color of the entire cell. now, i found some code from another thread that does this, but i cant seem to get it to work with more than 2 keywords. i need fine-tuning the provided code to do what i need it to do.

[URL]

the VBA code i used was this:

[Code].....

I was playing around with the example, the Cat_Mouse.xlsm, and when i modified the 'myList' and 'myColor' arrays, it does not work.

Cat_Mouse.xlsm

For example, I modified the code to add the word bat:

[Code] .....

When i run the macros, the word "Bat" does not become colored red. interestingly enough, when i substitute the word "bat" for the word "hat" in the "myLIST array, the word "hat" does change to the red font.

I am looking to use this code to address keywords in my excel file by coloring all key words red and i have more than 10 key words.

View 9 Replies View Related

Macros Really Slow The Another Macros Is Run

Dec 14, 2009

I have two macros. Macros 1 opens another excel file, counts the number of rows it has, inserts that number of rows into the master file and then copies the data over. Key code as follows (x3 for 3 worksheets)...
For k = 1 To numrows
Selection.EntireRow.Insert
Next k

Macros 2 'cleans' the appended data by systematically going through each row, checking if certain cells have data, and if not deletes the rows. Key code as follows (x3 for 3 worksheets)...

For l = lastrow To 12 Step -1
If WorksheetFunction.CountA(Range("B" & l & ":C" & l)) = 0 Then
Rows(l & ":" & l).Select
Selection.Delete Shift:=xlUp
edelrows = edelrows + 1
End If
Next l

Here's the weirdness. macros 1 runs fairly quick the first time out (few seconds). Macros 2 takes about 2 minutes to run (which I'm fine with). However, when I run macros 1 AFTER running Macros 2, Macros 1 goes from taking a few seconds to a few minutes.

View 11 Replies View Related

Version 4 Macros And Vba Macros In Them

Apr 13, 2007

how to use excel 4 macros. I do not even know where to put them. I have inherited some spreadsheets that have both Xcel 4 Macros and vba macros in them. (Well, I get a warning that I cannot switch them off when I disable macros on opening a workbook). I cannot even find the offending version 4 macros so that I can re-code them in VBA.

View 2 Replies View Related







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