Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


Ambiguous Name. Can A VBA Combine 2 Macros

I've got two macros that work beautifully apart from one another ... but put the two in the same Excel workbook and they bump heads. I get the infamous "Ambiguous name detected: Worksheet_Change"

I know enough about VB to get myself into trouble. So, I'm asking for help from a talented person to show me how to combine the two ... or another work around to get through this.

Here are the two sets of code in my sheet that I think are causing the ambiguous name problem. How can I work around this error?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim varFind As Variant
If Target.Cells.Count > 1 Then Exit Sub
If Target.Column 2 And Target.Column 9 Then Exit Sub
If IsEmpty(Target) Then Target.Interior.ColorIndex = 0

If Target.Column = 2 Then

Set varFind = Columns(16).Find(What:=Target.Value, LookIn:=xlFormulas, LookAt:=xlWhole)
If varFind Is Nothing Then
Target.Interior.ColorIndex = 0
Target.Interior.ColorIndex = Cells(varFind.Row, 16).Interior.ColorIndex
End If
End If

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
How To Combine 2 Macros
I probably have a odd request, but then I think I'm just different ?

I have an Excel Workbook with Col. A approximately 1/8" wide. The formatting of this col is that the cells are set to have the typing fit into the cell, therefore it becomes so small that no one can read it. Just what I wanted. If the user needs to read what's in the cell, they can click on the cell and read it in the formula bar.

Col. B is approximately 2" wide

1st, the user enters the Path and File name, with extension, into cell A34(example).

2nd, the user types in a File Name that they will best understand into cell B34.

The Workbook is now saved.

When the user wants to open that file, they click on the Name . . . Col B34 - Easily recognized by the user.

They then click either the Button that say's "Open Excel File" -or- "Open Word File.

The macro automatically moves the selection over to column A, then the file is opened.

Now what I need

I want to use just 1 button and I will name it "OPEN"

The 2 below macros work excellant and I still need the functionality of each. What I want is that 1st it trys to see if it is an excel file and if so, opens the file and stops.

If the macro determines that it is not an Excel file, the macro then goes to the Word macro and determines if it really is a Word file and if so, opens the file and stops.

NOTE: I want to point out that I still need all the checking etc that the 2 macros currently do.

Here are the macros

OPEN EXCEL FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

View Replies!   View Related
Combine 2 Macros Into One
I have 2 macros that work as I want them to. First one gets ride of formulas and formatting etc. and then deletes itself.

Sub Quote_Wrapup()
Application.CutCopyMode = False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Shapes("Picture 14").Select
Application.CutCopyMode = False..................

I don't really understand how to combine them so that they will work as one.

View Replies!   View Related
Combine Two Macros And Run Them On Double Clicking A Cell
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 Replies!   View Related
Ambiguous Name Detected ..
I need to use both of these VBA scripts in my excel project. The first is this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheets("Sheet2").Range(ActiveCell.Address).Value = 1 Then
ActiveCell.Interior.ColorIndex = 3
End If
End Sub

The second is this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lScrollRow As Long
Dim lScrollColumn As Long
Dim lTargetRow As Long
Dim lTargetColumn As Long
Application. ScreenUpdating = False
lScrollRow = ActiveWindow.ScrollRow
lScrollColumn = ActiveWindow.ScrollColumn..................

When I enter both into the script box and then try to run it, it says that there is a compile error with an "ambiguous name detected "worksheet_selectionchange"

View Replies!   View Related
Ambiguous Name Detected: FormatCell
my macros to search for the word "Cancel" in columns "T". Once found, I need the macros to make that entire row a certain pattern ( .Pattern = xlGray16)

There will be other wording in these cells that contain "Cancel" or "Cancelled".

A compile error keeps occurring. It says "Ambiguous name detected: FormatCell"..

View Replies!   View Related
Ambiguous Name And Naming Of Sub Routines
I'm running a sheet with three pieces of code (all blagged from these forums thank you) Two of the sub procedures have the same name "worksheet_change which generate an ambiguous name error. This I sort of understand. However I've tried changing the second one of the subs names to "worksheet_change1" and whilst the ambiguous name error goes away the sub routine then fails to function.

View Replies!   View Related
Ambiguous Name Detected With Constant
Option Explicit
Public Const ARK As String = "Inddata-ARK"
Public Const VVS As String = "Inddata-VVS"
Public Const KON As String = "Inddata-KON"
Public Const EL As String = "Inddata-EL"
Public Const LD As String = "Inddata-LD"
Public Const KØL As String = "Inddata-KØL"
Public Const OpDat As String = "Opdatering"

And then macro's under it... So the aboce is in module "INIT_S". Now in another module "RUN_P" I have a sub-rutine that uses these constants with a select case.
Likes this:

Sub OpEksInitNu()
Select Case ActiveSheet. Name
Case ARK
With OpEks
'more stuff
Case VVS
'more stuff
Case KON
'more stuff
End Sub

But when I try to run OpEksInitNu i comes with ambigious name with ARK as the error, later down I use another public constant. But i keep getting the ambigious name error.. What could cause that... I have tried to locate all ARK, VVS etc. to try to determine if it is used later on, but it's not! I only declare the constants one time, and no module is called ARK, VVS etc.

View Replies!   View Related
Progress Bar :: Ambiguous Name Detected
I want to include a progress bar in my macro and have got the code from another website. However, after the progress bar is displayed i cannot get it to move to the next line of code in the module. In the example i've got, the code in the user form window simply calls a sub called "main" and continues on through that sub. Whenever i call one of my sub routines an error box states" ambiguous name detected". This never happens with the sub called "main"? Why is this happening? A portion of the code is shown below. After "", the user form is displayed but the program will not move on to "get_blades" sub routine?

' Sub routine "browse_folder" selected to select folder
' containing the mea files.

UserForm1.LabelProgress.Width = 0

' HourGlass

get_blades (lookinname)
' Use sub routine get_blades


View Replies!   View Related
Compile Error Ambiguous Name Detected
Hello, Im using a script that allows me to autocomplete a data validation list using a combo box and the code shown below. However I am getting a compile error ambigous name detected and the following line is highlighted

"Private Sub Worksheet_SelectionChange(ByVal Target As Range)"

I know its because this is used twice but I am not sure what to do in order to fix this.

View Replies!   View Related
Ambiguous Name Detected Running Macro
I want to include a progress bar in my macro and have got the code from another website. However, after the progress bar is displayed i cannot get it to move to the next line of code in the module. In the example i've got the code in the user form window simply calls a sub called "main" and continues on through that sub. Whenever i call one of my sub routines an error box states" ambiguous name detected". This never happens with the sub called "main"? Why is this happening?

View Replies!   View Related
Compile Error: Ambiguous Name Detected: Worksheet_Change
Receiving the following error:

Compile Error:
Ambiguous name detected: Worksheet_Change

How can I resolve this? Is there a way to combine these two (2) statements?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$O$3" Then
Sheets("Letter").Range("A16:A26").PasteSpecial xlValues
Application.CutCopyMode = False
End If

End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "TextBody" Then
Sheets("Letter").Range("A16:A26").PasteSpecial xlValues
Application.CutCopyMode = False
End If

End Sub

View Replies!   View Related
Encourage Enabling Of Macros: Disable Macros When Opening Then The Worksheet Menu Bar And Other Command Bars Are Still Available
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 Replies!   View Related
Enable/Disable Macros When No Macros Are Present
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 Replies!   View Related
Hiding Macros From The Run Macros List
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 Replies!   View Related
How To Delete Another WorkBook Macros Using Macros
What is the commands or script for deleting a macro automatically using
another workbook macro.

View Replies!   View Related
Macros Really Slow The Another Macros Is Run
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
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 Replies!   View Related
Version 4 Macros And Vba Macros In Them
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 Replies!   View Related
Combine The Specified Value
I have 12 workbooks (one for each month), they have a list of assets to our company and a running total of all expenses for the month that they incurred. The 13th workbook is a yearly analysis of each asset. I need to transfer all charges into this worksheet.

So for example:

Worksheet 1 (January)

Column A Column H
Asset # Total Expense
5021 $3,041.52
970289 $242.08

Worksheet 13

Column A Column B Column C Column D
Asset # Asset Description January February
5021 Rivet Machine $3041.52 $345.65

So hundreds more machines for twelve months can take awhile to populate this info and very confusing when dealing with separate worksheets.

View Replies!   View Related
Combine Rows Into One
I have data as follows -

and want to combine lines by order so that data now becomes this -

View Replies!   View Related
Combine Xls Files
My question is do u know any sort of program that can combine 100 xls Files (all has only one sheet ) to only one huge file in just one sheet !

and yes all the sheets having same no of columns and rows of data !!

View Replies!   View Related
Combine Two Sheets Using Vba
How to combine two worksheets (sheet 1 and sheet2) to a sheet named “combined”?
Sheet 1 and sheet 2 contain data wich is filled up by using formulas. The data range is from col A to F with headers in the first row, the length is variable.

Here’s an example:

ColA ColB ColC ColD ColE ColF

33 44 46 84 36 567
10 12 56 98 100 64
0 0 0 0 0 0
0 0 0 0 0 0

ColA ColB ColC ColD ColE ColF........

View Replies!   View Related
Combine Many Columns To One
Essentially need a macro to combine the columns into 1 column.

Need a Macro to put everything in each "box" into one column, for example CU is the end of the first box, CV to GP is the second box ect. Essentially a box is the row where the yellow line is to the column where the yellow column is.

The problem is the setup of these colums change, sometimes they are bigger sometimes smaller and the spaces beneth it change. Sometimes I might have a column which goes to row 18 followed by 3 blank rows then the yellow box

I first design the first colum then select that and drag across to complete the rest ( my real file has links ect )

So I need a macro in which it can scan the first column up to the yellow line then put everthing within a "box " into 1 column, each )

then repeat the same process for other boxes with each box being put in its own column ( preferablly leaving an empty column in between )

THe file itself will help clarify any problem, if this request is not possible if it could combine every column into 1 column ( along with the spaces to the yellow line ) that would help also, i could manually cut each box into another column then.

View Replies!   View Related
Combine Files
I have a scenario here and i really dont even know where to start. If anyone can help me with some code for this project that would be great.

I have a folder that contains several subfolders (10-20). Within each subfolder is a number of excel files (the number of files varies) that contain 2 worksheets each.

What i am trying to arrive at is one file for each subfolder that has the first tab of each of the files. The original files contain links, so the values and formats must be pasted. It woul dbe great if all of the new files could be saved in the main folder among all of the subfolders.

It would be especially great if each tab could be named for its respective file and each new file for its respective folder.

View Replies!   View Related
Combine Several Spreadsheets Into One
I am so frustrated to combine several spreadsheets into all in one, and seperate all in one spreadsheet into several with the same header frenquently. Pls check the attached example excel spreadsheet., could anyone teach me how to program in vba to achieve the result as above?

View Replies!   View Related
Combine Two If Statements
Is there a way to combine two if statements below.


View Replies!   View Related
Combine IF With AND, And VLOOKUP
I need to lookup two different columns and if values match, then bring back one value:

For Example:
Data:CityNameAtlantaDaveNew YorkCharlieLos AngelesDanSt. LouisDanMemphisSteven

Lookup Table:CityNameCodeAtlantaDaveDAVNew YorkCharlieCHALos AngelesJavierJAVSt. LouisDanDANMemphisRobertROB

The formula I'm looking for would produce the following results:
If City on Data matches the city on Lookup Table, and the name on data matches the name on Lookup Table, then bring back the code on Lookup Table.

Result would be:
Results:CityNameResultsAtlantaDaveDAVNew YorkCharlieCHALos AngelesDanWill be blank, as the names on Data and LookUp Table don't matchSt. LouisDanDANMemphisStevenWill be blank, as the names on Data and LookUp Table don't matcm

View Replies!   View Related
Two Formulas Need To Combine As One
I have two formulas that i need to combine as one, but i dont now how.

This is the other formula:

=SUMPRODUCT((Huollot!I2:I500="Ty”n alla")*(Huollot!K2:K500="Warranty")*1)

The other one:


the biggest problem is that this formula does not work as it is. Or is there some other function than networkdays that i could use?

The purpose of the formula is to count how many "objects" that are in service have been there for over 20 days. There a a few other criteria also, but sumproduct takes care of that. Can networkdays even be used the way i´m trying to?

View Replies!   View Related
Combine SUMIF With IF
I am trying to use SUMIF as part of an IF statement, What I am trying to do is, for example, if a column has two values M and P, then SUMIF only those rows that have a corresponding M, and not calculate the P's.

View Replies!   View Related
How To Combine Two If Statements
What I want that cell Q4 displays:
1) When the current date is larger than the date in O4 AND is smaller than the date in P4 than say "Update!"
- When the current date is larger dan P4, say "Expired!"

Every other scenario the cell must be blanc.

To do this I have made two seperate formulas:
1) =IF(AND(NOW()>=O4;NOW()P4;"Expired!";"")

How do I combine these into 1 cell? I have tried allmost every combination, I'm ready to throw my monitor through the windows

View Replies!   View Related
Combine The Columns
I need to find a way i can easily combine a1, b1, c1, d1, and so on, about a 100 of the, i need to combine, each one has different text that needs to become together. I know one forumula =a1&" " &b1&" " &c1, but doing that for about 100 colums, would take for ever, is there a easier way?

View Replies!   View Related
Combine PDF Using VB Codes
I am looking out for a macro by which i can combine multiple PDF's into one through excel using vba codes.

Please note that:
> all these PDF's are in one folder
> the code needs to be dynamic (i can have an option to combine selected PDF's
> i am working in excel 2007
> i have acrobat 8.0 installed

View Replies!   View Related
Combine The IF And OR Queries
Trying to write an IF query looking for multiple returns that would equal the same result.

I have a series of number where the last digit would result in the same return if the digit were 1 or 6, 2 or 7, 3 or 8, etc.

1 or 6 = 1
2 or 7 = 2

I have been trying unsuccessfully to combine the IF and OR queries

View Replies!   View Related
Combine The Cells In A1
In cell B1 I have the number 1
In cell C1 I have the number 1031000

I know how to combine the cells in A1. I am getting a result of 1-1031000

What I would like to happen is that 1 becomes 001.

Ending result is 001-1031000

problem is that cells in B could be one, two or three digits.

On a small scale I could fix manually but i have over 15,000 rows to deal with

View Replies!   View Related
Combine The Cells
i m working on a spreadsheet and i need cell A+B=C..

Cell A has a first name (John)
Cell B has a last name (Smith)
Cell C has last name then first name seperated with comma

View Replies!   View Related
Combine Lines
I have a text file which is wrapped and i am trying to read it through VBA. I want to combine wrapped lines in one line

for e.g.:


View Replies!   View Related
Combine 2 Functions Into 1
I tried to do a search for this but the search function was not working.

I have an excel sheet that I can scan Mac address into. The reason I created the sheet is because when I scan them in they are uppercase and do not have separators. I would like to combine 2 excel functions into 1

This one


and this one


View Replies!   View Related
Combine Number In One Row
I want to combine number in one row.

Column A

Need to be in column B. 12,13,14,15. I tried “=A1&”,”&??

View Replies!   View Related
Combine Vlookup & Max
Is it possible to combine Vlookup & Max?

In column A I have product codes some of which are repeated, in column B I have costs for the relevant product codes.

I want to vlookup the product code on another sheet, then Columns A & B picking up the cost in column B but if there are mutiple entries I want to pick up the highest cost out of all the entries with that product code.

View Replies!   View Related
Can I Combine VLOOKUPS In A Formula
Basically i need to type in a formula in sheet 1 under each of the months that will match the account name and location from B1 and C1 to the data range in sheet 2 (Columns B and C) and return whatever value is listed on sheet 2 under column E. My gut tells me I need to use multiple look ups but I've tried this and got numerous errors.

View Replies!   View Related
Combine Two Formulas With Average And Sum
Working on the same simple chart NBVC helped me on, but this is for AVERAGE instead of SUM and with an added variable.

View Replies!   View Related
Combine Data From Different Workbooks
Is it possible too do this if they are on the same computer. Lets say I want all the data on page3 in one workbook, data on page2 in another and have it show up in another workbook. If this can be done can it delete cell entry that match?

View Replies!   View Related
Combine Data From Two Worksheets To One
I am trying to copy raw data from two worksheets (Sheet2 = "550 Report (raw data)" & Sheet3 = "305 Report (raw data)"), that I cannot edit, over to a new worksheet (Sheet1 = "Exception Management") that I can edit. I have been successful in coding Sheet2 to come over correct, but am having problems with Sheet3 because of a few issues:

1st: Column A on both sheets contain a unique alpha-numeric identifier that can be used to identify records that can be combined. Sheet3 will sometimes contain multiple records for a single Sheet2 record.

2nd: Matching rows from Sheet3 will always be done based on Sheet2 column A (So I need to search through Sheet3 column A based on all values in Sheet2 column A).

3rd: The dataset is MUCH larger than my example files. Sheet2 normally contains 700+ rows of unique identifiers with 56 columns of data. Sheet3 is pretty much as-is, except ususally 1/10th the number of rows as Sheet2.

Here is the code I am experimenting with:

Private Sub CommandButton1_Click()

Sheets("Exception Management").Select

' Prepare Exception Management sheet for new data

Cells.Select .......

View Replies!   View Related
Want To Combine Celll Values
I have a sheet in which there ara $ and Cents but in the bottom i want to sum them together. How can i do that?

View Replies!   View Related
Combine Vlookup And LEFT


I combined the first two formulas into one (the third one) but it is not working. I get an N/A result.

View Replies!   View Related
Macro To Combine Tabs
I'm new to Macros and need your help. I've read online but can't find instructions on completing what I want.

I have a workbook with about 60 tabs that has various numbers of rows. I want a macro that will combine all the rows from each tab onto a new tab.

Is there an easy marco that i can do to acommplish this?

View Replies!   View Related
How To Combine The Data In A Row Into One Cell
I am trying to combine the data in a row into one single cell.

For example,

B2= A1 & A2 & A3 .... until the end of the values in column A

I need this to be a macro so that when I enter values into column A manually and press the macro button, it will combine them into cell B2.

View Replies!   View Related
Search And Combine Cells
I need to search and combine cells based on a specific set name. I would be just as comfortable if it automatically found similar names without me entering the names I would like combined. This is not required though.

EX: Search for John in Column A
Find 2 rows with John
Add each column from row with name John together individually


Name----Number 1 -----Number 2
John------ 1 -------------3
David----- 55----------- 65
John------ 5 -------------2

In the end I would like:

Name -----Number 1----- Number 2
John------- 6 --------------5
David-------55 ------------65

Then I'll be recalculating fields and repeating the macro for another name (this part I can handle). The current quick macro I made just combines highlighted cells, which is OK but time consuming. I took VB in highschool, but remember none of it!

View Replies!   View Related
Combine And Sort Two Tables
I'm analyzing and charting performance data from two different boats. I am attempting find a way to combine the two charts into a single chart that is sorted by MPH as per my manually sorted example.

View Replies!   View Related
Combine Multiple If Statements With OR
=IF(VLOOKUP(B3,'Rep List'!$E$1:$I$10000,5,FALSE)=OR("BH","AC","#N/A",0),VLOOKUP(C3,'Rep List'!$A$1:$C$1000,3,FALSE),VLOOKUP(B3,'Rep List'!$E$1:$I$10000,5,FALSE))

I'm getting the "#value" error - the vlookups are working independently

View Replies!   View Related
VBA Script For Combine Headers.
The raw data that I download breaks up the header into 5+ rows.

Ex: "Patient Med Rec No"

Would be all in column E but in different rows:
Row 1: Patient
Row 2: Med
Row 3: Rec
Row 4: No

Some have 5 rows of headers, some with 1 so its different for each header title.

Sometimes I have over 30 columns to fix.

Is there a way to insert a new ROW at the top and concatenate everything? Even if some rows have blanks and possibly more that 5 rows?

View Replies!   View Related
Copyright © 2005-08, All rights reserved