Perform compare of multiple selected columns

I am looking for a way to program the following using VBA and a command button:

If user selected columns 4, 7 and 8 then compare this
       if cells(2,4) = cells(2,7) = cells(2,8) then cell(2,12) = "ok"
       else cell(2,12) = "check"

Basically, how can I get the column number of what columns are selected to 
compare all data for each column selected.
0
Utf
1/19/2010 6:22:01 PM
excel.programming 6508 articles. 2 followers. Follow

1 Replies
1132 Views

Similar Articles

[PageSpeed] 31

Hi

This should get you started:

Sub aaa()
For Each col In Selection.Columns
    c = c + 1
    Select Case c
    Case 1
        col1 = col.Column
    Case 2
        col2 = col.Column
    Case 3
        col3 = col.Column
    End Select
Next
Debug.Print col1 & ", " & col2 & ", " & col3
End Sub

Regards,
Per

"domleg" <domleg@discussions.microsoft.com> skrev i meddelelsen 
news:32DA804D-9292-49DE-BABD-377CF11BE83E@microsoft.com...
>I am looking for a way to program the following using VBA and a command 
>button:
>
> If user selected columns 4, 7 and 8 then compare this
>       if cells(2,4) = cells(2,7) = cells(2,8) then cell(2,12) = "ok"
>       else cell(2,12) = "check"
>
> Basically, how can I get the column number of what columns are selected to
> compare all data for each column selected. 

0
Per
1/19/2010 6:36:12 PM
Reply:

Similar Artilces:

selecting all shapes
How can I select all shapes on a sheet other than holding the shift down and selecting one by one? Using Excel 2000 Maybe Edit|Goto|Special check Objects ADK wrote: > > How can I select all shapes on a sheet other than holding the shift down and > selecting one by one? > > Using Excel 2000 -- Dave Peterson ...

How do I mix column chart types?
I would like to create a column chart where each x-axis point (date) has 2 columns, one for forecast and one for actual, but I would like to subdivide the "actual" bar into 3 separate sections. Any ideas?? I have tried pivoting and such, but to no avail. Thanks. It's all about arranging the data: http://peltiertech.com/Excel/ChartsHowTo/ClusterStack.html - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ Ramesh Narasimhan wrote: > I would like to create a column chart where ea...

Excel Data Consolidation ; Multiple workbooks
I understand how to use data consolidate on multiple worksheets in a single workbook. My case is multiple workbooks, each with a "roll up" of data using data consolidation. I am trying to consolidate the roll ups from the multiple workbooks into a Grand Roll up and having a bear of a time making it pull together. Help! Thanks. A Data Consolidate will work with multiple workbooks. It's just a matter of adding the right reference, e.g.: [SrcBook.xls]Sheet2!$B$2:$D$12 What's your specific problem? -- Jim Rech Excel MVP ...

Multiple Records in Tables
I have four tables that each contain a unique account number for a customer and a service rendered. I want to be able to query out the various combinations of who had what done. Example one table has an account # and tire rotation. The next table has account # and oil change. The next tune-up and the next air filter. I would like to query who had just a tire rotation, who had a tire rotation and oil change, who had a oil change and air filter and so forth. Any help is greatly appreciated and thank you in advance. Tim What would you do? Same. It goes to Ungratefuls. ...

Multiple Emails using outllok 2003
AFter installing all updates and security features, I find with just a few specific emails ID's I use, I get 2-3 emails that are duplicates of each other. I tried deleting then re-creating the emails ID"s in outlook, but I still get multiple emails from one person who sent only one email. Yet just a few ID's will display copies of the origignal. Anyone help? Thanks, Greg Do you have Norton or McAfee installed scanning your incoming and outgoing mail? If yes, try turning it off and see if it improves. --� Milly Staples [MVP - Outlook] Post all replies to the group to...

Some of the data in a column in view is being truncated
I created a view that creates a single column with a long string. this string is used to export to a .txt file to be sent electronically. Well if the results are sent to grid all of the data is there, but if its sent to a file or text then some of the data has been truncated. The length of the column varies, but its about 278 chars long. Any knowledge as to why its doing this? -- Thanks for your help Are you sending to the .txt file via the SQL Server Management Studio query window? If so, its default setting is to limit strings to 256 bytes. You can set this in the qu...

vba macro to perform custom reporting -transpose from rows to columns
I have one workbook and two sheets 1 sheet has data for automated test scenarios that may be run up to 3 time if they don't pass on the first or second try Sheet1: TestSet Test Result reason if failed 1 pass 2 pass 3 pass 4 fail x 4 fail y 4 fail z I want to create a summary report that looks like Sheet2 for the Sheet1 logs above test run1 result test run2 result test run 3result Sheet2 Testset result1 result2 result3 1 pass 2 pass 3 pass 4 fail fail fail So if a testset is executed more ...

Comparing and contrasting columns
I really know very little about Excel and I need this answered for my job. Any help would be greatly appreciated. In my job I'm often given two spreadsheets with account numbers and first and last name. One sheet has all of the accounts that we are given to bid on (with the seller's account number) and one sheet has the accounts that we actually bought (with seller's account number and our new account number). I need to know if there is a way to compare the two and extract only the accounts that are alike and our new account numbers and put them in a new column. I hope someone fol...

How can I sort my address book by 2 or mopre columns?
I want to sort my address book by Department first, then, secondly by Name. Is this possible? I have Outlook 5 for Macintosh installed on my Macintosh Snow iMac. Thank you for any help. Lauren -- Lauren D. Ansaldo, Employment Counsellor Employment Services Saskatoon Open Door Society Saskatoon, Saskatchewan, CANADA You might want to ask this in an Outlook Express group for the Macintosh. This group focuses on Outlook from Microsoft Office for Windows. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.com and f...

performances
performances Hi, I am writing c++ application in vc++ 6 the application use a lot of cpu processing (math calculations), I am running the application on Win-XP, p-4 2.8 HT! What is the best way to compile my application so it will run faster? What are the best ways to write or build my application for faster running? What i the different betwine processor type Blend* inn the C/C++ tab of the project setting and the other option??? Thanks! "Dave" <dbg@012.net.il> wrote in message news:eY8jUE38EHA.3756@TK2MSFTNGP14.phx.gbl... > performances > > Hi, > I am wr...

Countif Formula w/ Multiple Conditions
Can someone please help me? I am trying to create a formula in Excel that will count the number of rows that contain specific information in 2 columns. More specifically, if column A:A is titled Regions and K:K is titled Metric Met, I want to know how many times for the Region Australia, Metric Met=Yes. Please let me know. Any information will help. Thanks, Denise --- Message posted from http://www.ExcelForum.com/ Hi Denis, you can use the function SUMPRODUCT. Example =SUMPRODUCT((A1:A9999="Australia")*(K1:K9999=Yes)) Also some links http://www.cpearson.com/excel/array.h...

How to select other form's Treeview item #2
Examples: I want create new project and two Button. (Button Click: Control other program's Treeview like outlook have Folders. ) When I click button1 Outlook Express folders selected item is 'Inbox'.click button2 selected 'newsgroups.borland.com' ...

Adding Column Headings from Sub-records in Views
I am trying to create an "advanced find view" that incorporates not only column headings from within that record type, but also from sub records. I.e. All Accounts, the programs the account currently has and the opportunities. When I click on "add columns" I can only choose column headings related to accounts. Any thoughts on this? Crm currently does not support this behaviour. If you want this kind of view you need to build it your self in a custom ..aspx page which can mimic the CRM look & feel. -- Patrick Verbeeten (MCSD) Lead Developer Aviva IT Web: avi...

same data multiple worksheets
I need to be able to have agencies type in a Consumer name and Agency name, and have the data automatically fill in on the next page of the worksheet same place for both. Please help, and explain so I can understand, I am not an expert in Excel, or computer talk... ...

KB for Performance Optimizer trouble
In the process of moving EDB files from a crashed server to a new server built with same name, etc, but different platform (from NT to W2K Sp4) I found the Performance Optimizer would not allow me to move files to different volumes. A quick google search showed because of SP4 I needed to contact Microsoft for the patch but when I called they said I needed the KB article and I searched and searched and even none of the 'MVP' replies saying 'contact microsoft' had the KB number. After having the MS rep hold the line while I was scouring google and retrying the process to get the ...

Can combobox selection place another value in spreadsheet?
I have a combobox where the user selects a city. The cities come from a spreadsheet where all the cities are listed in one column, and all of their zip codes are in the column next to it. How can I allow the user to pick a city, while putting that city's zip code into the spreadsheet? Astello If this is a combobox from the control toolbox (ActiveX) then set the ListFillRange property to the address of the list (e.g Sheet3!$A$1:$A$100), then set the LinkedCell property to a cell that will return the value of the selected item in the combobox. I usually set this to the cell 'unde...

How can I transpose rows to columns in a large worksheet?
I have a worksheet with 1268 rows and 31 columns. Ideally I need all the rows to be converted to one column, although I believe this is impossible without some additional manual steps. Every time I attempt to copy/transpose my rows to columns, I receive the message that the paste area does not match the size of the copy area. I have tried transposing a few rows at a time. I have tried transposing ONE row at a time. Each time I try, I either receive an error message, or get the #VALUE! error message in the cell. I've tried TRANSPOSE and MINVERSE. I would prefer NOT to do this m...

column headings of days
I have a query that is using a heading of Format([fld1date],"Short Date") and with no column headings properties. It gives me a sum value based on the date ranges that i specify. Normally this has worked. Now I have linked some of the queries behind the cross tab query to a form value and I get an error. It identifies that the expression is not valid field name or expression. In my investigation and found that if i put column headings like "Jan","Feb","Mar" the query works but the data is not accurate. Any suggestions Thanks Tim, Hi Tim, if...

Business Contact Manager, performance sacrifices?
I'm hoping we can all learn a little about Business Contact Manager... After some initial difficulties that were resolved by 1.5 hours with Microsoft and some great ideas from Patricia Cardoza's new book, I've got Business Contact Manager running smoothly. That's a good thing because I provide support and training in Outlook to clients and want to be able to recommend this new add-on. But is it ready to recommend? Here are two things that seriously bother me: my contacts take so much longer to load and sort. Searching from the "Find a Contact" box formerly t...

Multiple Worksheets #2
Hi Anyone out there who can tell me an easy way to export Excel data in multiple worksheets? I have a workbook with about 80 worksheets that are identical informat. I am trying to export the data to Access or move the data to a single worksheet in Excel. Any tips? Sources of info? Help files? I can't find anything on the subject. And thank you for your support. JMcG Hi John For a single worksheet try this http://www.rondebruin.nl/copy2.htm For Access look here http://www.erlandsendata.no/english/index.php?t=envbadac -- Regards Ron de Bruin http://www.rondebruin.nl "John M...

can i do multiple plots on 3d chart?
I have various data sets that I want to plot on a single 3D chart to compare peak responses. Is this possible in excel? What kind of 3D chart? Can you use the corresponding 2D chart type? In general, you are better off not using any 3D charts, and especially not Excel's 3D charts, which mostly consist of 2D data with a fake third dimension. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ "mrplec" <mrplec@discussions.microsoft.com> wrote in message news:98A0BF60-D8A6-49FD-A405-B...

COUNTIF with multiple disjoint ranges, same criteria
Is there any way to specify multiple disjoint ranges in one COUNTIF? I.e. something like COUNTIF((A1:C3,D4:F6,G7:I9),"Y") I want to avoid COUNTIF(A1:C3,"Y") + COUNTIF(D4:F6,"Y") + ... -- � 2005 Kurt Swanson AB This formula works as long as it is not located within A1:I9 =SUMPRODUCT(--((A1:C3:D4:F6:G7:I9)="Y")) Does that help? *********** Regards, Ron XL2002, WinXP-Pro "Kurt Swanson" wrote: > Is there any way to specify multiple disjoint ranges in one COUNTIF? > > I.e. something like COUNTIF((A1:C3,D4:F6,G7:I9),"Y"...

How to add a Vertical Line to a Column or Line Chart with two axes already in use?
Hi All, I need to add a vertical line to a column / line chart combo where the secondary axis is already in use. I have ready through John Peltier's site (http://peltiertech.com/Excel/Charts/ComboCharts.html) and specifically the two options he has under the 'Special Effects and Features' section for adding vertical lines to a chart, but both require the use of a secondary axis which is then hidden. That is not an option for me as I am already using that secondary axis. I am currently using a line object drawn over the top of the chart object and manually positioned on the cha...

Perform function...if?
Hi I have a workbook that I'm continually adding data to daily. and I also have another workbook that I want to perform calculations, but I only want the calculations performed IF there is data in the first workbook... Here are the two formulas the way they are now... ='Stock Return Data'!J24*0.25 ='Stock Return Data'!J24-'Tax Data'!A14 How can I tell both these functions, to only perform if there is data on the original worksheet? Thanks, Confused Man Hi try =IF('Stock Return Data'!J24<>"",'Stock Return Data'!J24*0.25,"&...

can multiple threads calling the same dll at the same time?
can multiple threads calling the same dll at the same time? Is it thread safe? >can multiple threads calling the same dll at the same time? Sure. >Is it thread safe? It depends if the code you're calling in the DLL is. Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq ...