Macro That Compares Cells
May 17, 2006I'm trying to write a macro that compare 2 cells. I can't figure out what is wrong with the code i have attached. It keeps giving me a fatal error.
View 6 RepliesI'm trying to write a macro that compare 2 cells. I can't figure out what is wrong with the code i have attached. It keeps giving me a fatal error.
View 6 RepliesIn cell M32 there will either be an O or the cell will be blank. In cell T51 I had placed an IF statment like this:
=IF(M32="O","","X")
Now that works ok but there is a glitch on my part. If T51 is blank because of M32 containing an "O" then the user will also enter a number into T51. Because I was using an IF formula in the cell it gets overwritten because of the user needing to enter data in the cell because of M32 containing a O. How do I write a macro so that a similar formula is used but still able to enter data manually without overwritting the formula?
I need to write a macro that compares the numerical value of 2 cells and give me a result as described below:
All the numbers would be either whole numbers or whole numbers + 0.5
Example 1:
The two values are both whole numbers then no action is taken.
Cell A = 5
Cell B = 5
or
Cell A = 7
Cell B = 5
Result = No action taken..................
this is an extract from a pivot table:
A B
N-CONTROX 18-jun 02-jul 16-jul Q-BETACICL 22-jun 01-jul
The left column is the product, the right the delivery day.
I need to Check and extract each product delivery days. For example, for Q-betacicl I should:
1.- in cell f1, use a Vlookup function to extract 22-jun. that´s done.
2.- in cell f2, use an If function that compares the cell below Q-betacicl with the cell below. If it´s 0 (like this case) it should extract 01-jul
I used this and excel didn´t even let put the formula, arguing some error I ca´t find:
=IF(OFFSET(Vlookup(E6;$A$5:$B$27;1);1;0;1;1)=0;Offset(Vlookup(e6;$A$5:$B$27;1);1;1;1;1);0)
Basically this says:
Look for a value equal to E6 (q-betacicl) in matrix A5:b27, and if the cell immediately below it = 0, copy the value to the right of that cell (the one below it).
In the case I showed, for Q-BETACICL, it should copy 01-jul. For N-CONTROX it should copy 02-jul.
My program assigns a variable one of three values - either "Lancaster", "DeSoto" or "Cedar Hill". My string compares for Lancaster and DeSoto work fine but can't get anything happening for Cedar Hill.
I looked at the value of the variable and it appears to be correct. However, when I did a StrComp for the variable and the string "Cedar Hill", they did, of course, not come out as equal.
I am currently trying to take a list of people who have log in times at work however if they log out then back in the result is what you see below.
What I am looking to do is match the find the name then find the earliest time (login Column C) and then the last or latest time (log out Column D)
A B C D
John Smith64676076:02 AM6:13 AM
John Smith64676077:25 AM11:27 AM
John Smith64676212:08 PM4:01 PM
John Smith64676076:13 AM7:25 AM
Would like a formula as I have another Tab on the sheet that looks up name and compares against a schedule to see if the person was late or left early.
Is there a Function or compound Formula that compares the values of two ranges and returns True/False ?
Something along the lines of : AreRangesIdentical(Range1,Range2) returning True/False.
I have played with some array formulas but they seem to compare the two first cells only.
I know one can easily come up with a UDF that loops through each cell and returns once a cell is found whose counterpart is different but i am looking for a solution that doesn't use a loop.
I've modified this macro I found on this forum, all it does is compares 2 lists of 6 digit serial numbers and and then tells me which numbers are in list 1 that are not in list 2.
However, I want to modify it so that it also gives me the numbers in list 2 that are not in list 1 (put into column F). I then need it to cut the matching serial numbers (in columns A and B) from sheet 1 and paste them into sheet 2.
I would like to build a graph that compares 2 sets of data but only plots 1 dot where the two intersect. I have seen this graph made by others in Excel but I do not know what it is called or how to make it. An example data set is below.
ID Age Height (cm)
1 5 125
2 7 140
3 8 138
4 11 152
I would just like to plot the location where the age and height for the ID's cross and not 4 plots with the age and 4 plots with the height.
I have a workbook that compares two sheets of data by taking the difference between the two. Some of the cells contain N/A for value, so when I take the difference of two sheets, it gives me #Value! error. My question is how can I format it, so when the cell contains text it displays N/A or if its a value: it takes the difference and populates the value.
View 9 Replies View RelatedI am trying to create a formula that compares month over month data. If the prior month is 0 I get an error. I am having trouble with incorporating ISERR into the formula to eliminate the error.
=IF((C26-B26)/B26
am making Excel for private use, i need the following makro to be active, here is the idea because i didnt yet work with makros at all:
If A1 = False
then Range B1:D1 will be locked cells
If A1 = True
then Range B1:D1 will be unlocked cells
Those rules apply to 1 day in the year.
the range A1:D1 will be copied about 400 so the makro should be active to each day separatly.
Check the picture attached for example of one day
I need a macro to get the values from cells D29 and H24 in the Resource Calculator sheet and populate it into cells N8 and O8 in the Input form.
Users will then be able to change the information in the calculator and click the macro again to populate N9 and O9 and so on.
Is there a way to do this?
I've attached the file for you to see.
1st - Need a macro to change a range of cells colours based on a single cell having a value greater than 0.001. ie. cells A1 - G1 need to change to grey based on cell F1 having a value greater than 0.001 entered in it?
2nd - Also a macro for deleting the text contents of cell C1 based on cell F1 having a value greater than 0.001. Therefor if cell F1 has a number greater than 0.001 it changes the colour of celss A1 - G1 and also deletes the text in cell C1?
I need to combined all non blank cells in a given row into 1 cell. But within each row i have 5 phases that the values fall into, which is denoted by the 1st charter 1, 2, 3, 4, or 5. for example, in a given row i have 1-a, 1-c, 2-d, and 1-f and these values occurs in non consecutive columns starting from G to ALR. I need a macro that sorts these values in one of the 5 phases. So in another sheet the macro would combined [1-a 1-c 1-f] in Phase 1 and [2-d] in phase 2. and if there are other phases it would put them in the appropriate cell.
See attached workbook : Work Order Summary Sheet.xlsx‎
However, in addition to what the macro already does, it is possible to add another work sheet in the same work book that outputs the values in separate cells? It also has to output the data in order: for example, in the first work sheet the data is inputted at random and has spaces but the macro will have to remove all the blank cells and output them in order based on the first value in the test string, 1, 2, 3, 4, and then 5;
input:
blank 3-x Blank 1-y blank 2-z 1-k
output:
1-k 1-x 2-z 3-y
Put in a statement within a Macro that populates cells with the values that I want it to but instead of populating all at the same time, is it possible for the values to be delayed.
I have designed a mock spreadsheet (attached) it has two columns 'Before' and 'After'
After = Before values (in this mock)
When you press the button, the values are populated straight into the 'After column' can we add the delay between the values? So that the values dont come up straight away.
I would like to run a macro that would check if the date in the first cell of row is in the past.
If yes, then it would clear contents of cell in B,C,F,I,L of the same row (PLAN + SHIFTS). Or even better it would set them to 0 (zero).
Then it would hide the entire row. Is this even possible?
Please see the example: Excel.JPG
Macro to clear cells with numbers but no cells with formulas with in this macro:
Dim i As Long
i = Range("E3")
If i > 0 Then
' Copy range
Range(Cells(6, 10 + i), Cells(500, 17)).Copy
Range(Cells(6, 10), Cells(500, 17)).Select
' Paste special
ActiveSheet.PasteSpecial Format:=2, Link:=1, _
DisplayAsIcon:=False, IconFileName:=False
' Clear i columns on the right
Range(Cells(6, 18 - i), Cells(500, 17)).ClearContents
End If
End Sub
The range is where the cells with numbers need to be cleared but not the ones with formulas.
I have a worksheet that I want to populate with specific data from another worksheet.
If all of the following are met:
1) Column A equals "763" and
2) Column K is formatted Red (255, 0, 0) from conditional formatting
3) Column P is blank
Then in my blank worksheet I need to display the data from Columns A, B, D, K, O
I have a list of names and have created a macro to be started after I click on the name I want then run the macro.
I want to use the same macro for any of the names by clicking on the name then running the macro. Obviously the way it is now, when I click on a different name and run the macro, it runs the macro only for the name it was created.
Is there a way to do this without creating a macro for each name?
i need to implement this formula in a macro for all the rows in the worksheet.
E11=INT(SUM(DJ9:ER9)/(3*20*15)*100)
this formula is to find the sum of all numbers from DJ9 to ER9 and then multiply and divide by integers...
how do i put this formula in a loop so that it finds the sum of all numbers tilll row number 50?
What my code needs to do: It needs to verify data in column rows say for this example columns A to C and infinite rows. It needs to verify the data in this order A1, B1, C1, A2, B2, C3 etc. (One of the part I have problems to do) It also needs to add to a row/cell "1" when certain conditions. (In the same line as the last checked data in the column "D" say for exemple last data that was checked is "A3" well the 1 must be written in "D3". The conditions are simple the first Data the macro encounters must be higher than 0.25 and all following data must be higher than 6, whenever the next data is lower than 6 or empty add 1 to the corresponding D row and restart at the 0.25 cell "checking".
View 2 Replies View RelatedThe current code which I did can only pop up a caledar when I click on cell D4. Is there a way I can program it such that, if I click on D5-D7 and E4 - E7, the same calendar will pop out also?
Also, there bug which I found in this code, that if I click on D4 once, the calendar will appear. After I select the date, the calendar dissppear. The bug will occur when i try to click on D4 again, the calendar will not pop up. it will only appear after i click on any other cell, then back to D4.
I have a row of cells with names. Alex, John, Martha, Jim, etc.
Each person has a list of data under them. I have a master column of data. Depending who is on duty today, I want the macro to find the person and then copy paste special the master column over the person column.
Thus, in the macro code where it says
Find(What:="John",
I want it to refer to a specific cell. I.e. what:=$E$4.
Then it must go to the cell it found and copy paste the info in.
I've recently got into using excel for more complicated work but still have a less than basic knowledge as I'm attempting to teach myself through trial and error. What I'm currently working on is a simple macro that downloads data from a website (which I've done) but ideally I'd like to have this macro recreate the data roughly every 30 seconds/minute and also have this data recorded next to the existing data rather than on top of it. I realise that you can import data from the web using the standard tools and can set it to reset every 60 seconds but I don't think you can get it to reload the data next to it which is why I was considering a macro.
View 10 Replies View RelatedI have a worksheet change event that prevents a person from entering a positive number in 2 different cells. If they enter a number in one cell, the other locks, and vice versa. The code is below.
View 4 Replies View RelatedI have a need and thanks in advance to everyone who can help me with this: Run a macro to copy from cell B2 in worksheet2, then paste that into every cell that has the value = 1 in worksheet1.Range("B2:Z40"). Cells in range B2:Z40 will be updated each week with the value varied from 1 to 10.
View 5 Replies View Relatedis there any way where instead of selecting a cell one by one and run a macro, i can just drag the cell with the macro across other cells like how a formula runs?
View 5 Replies View RelatedI'm trying to set up a macro that locks or unlocks a column depending on what is put in the column before it.
at the moment i've got the code written in the worksheet