Setting Ranges For Comparison Operators
Jul 21, 2009Is it possible to set a range using comparison operators? ie. if a number lies within x and y then such and such happens.
View 6 RepliesIs it possible to set a range using comparison operators? ie. if a number lies within x and y then such and such happens.
View 6 RepliesIm trying to set a range using a named range and dont know the best way to do this. so far ive got
Set rDataRange = Range(Offset("datastart",1, 0) & ":" & Offset("datastart",LastRow, 0))
datastart is the named range in the sheet and im trying to make a new range that starts 1 row below where datastart is and end where lastrow is. not sure where i messed up on this but i get errors when i try to run this
So I've tried this a few different ways and every time I get the 1004 error: "Unable to set PrintArea property of PageSetup class"
Basically I have a macro that goes through a workbook to hide certain rows and columns based on some user inputs. After doing this I would like to set up appropriate print areas on certain sheets so that when you go to print anything it comes out clean. I thought this would be easy but I'm stuck.
The Plans variable in the code below is an integer from the user input. Think of this code as grabbing two separate boxes and setting them as print areas, which I've know I can do manually because I've tried it.
What's wrong with the following code?? (I've also tried using the union function here, to no avail)
I am a novice excel and VBA user, but have been working the past few days on a project to create a data entry form (using Excel 2003 on WinXP). I have the userform created and the textboxes working fine for inputting data into the spreadsheet. I also have comboboxes set up, and if I directly input data into them, they also input that data. So far, so good.
(problem)
Here is my issue: I want the comboboxes to use dynamic / variable ranges, so I have been trying to set up the ranges by defining them as names. I've come across a bunch of examples, but none of them seem to work (all produce an error that the formula is not correct or instead seem to reset the name to just the first cell when I input it).
My sheet is called Dropdown Lists, and there is a column here for each combobox. Each row in a column has the options I'd like used for that combobox. So I am basically trying to name a range as the entries in just one column.
This is what I have been working with most recently in the Name - > Define dialog box that according to everything I read -SHOULD- be working:
=OFFSET('Dropdown Lists'!$A$3,0,0,COUNTA('Dropdown Lists'!$A:$A),1)
This produces an error, that when you hit OK highlights "$A$3" - and if I remove the $ symbols, it skips then to the "$A:$A" until I remove THOSE $ symbols, and then excel will accept it, but when I go to the name, it only highlights one cell. I thought maybe that was OK, but when I tried putting the name into my rowsource, nothing happened - so apparently not.
Questions:
(main question)
- Why will this not input correctly when everything I read suggests this format? Am I not handling the space in the worksheet name correctly (with ' ')? Sometimes excel will automatically add in " " between = and OFFSET and the closing at the end, but this also has not helped. One source I read even recommended taking off the = at the start (also did not help). Am I missing something here?
(follow-up questions)
- Why are you supposed to use "$" before the cell references anyway? I've looked for an answer but haven't found one yet... is that for when you make cell references to cells on an external worksheet?
- What is the "Add" button for on the Name -> Define dialog box? I'm confused to if I am supposed to use this to add the name to the list of defined names, or just hit OK?
- At the bottom of the Name -> Define dialog box is the "Refers To:" field with the formula. On the right of that you can hit a button to go to what seems like another (smaller) formula input box. Why would I ever use that when I could just type it in on the previous box? There is no label for it so I am guessing here - but does it actually do something else (like you need to go to that smaller dialog to input new formulas and the previous box is only for -viewing- formulas, or?)?
I have some code to plot a column chart of data but it isn't working as expecting at the moment. The code is below. The variable binCounter is a count of how many cells in a range that I want to plot on the chart.
However, what I am finding is that the first couple of cells in the range appear as the series name with the rest appearing as the data in the chart. Secondly, the chart appears with the axis labels 1,2,3 etc when I have some custom ones I would prefer to use. How do I go about setting this property, as I can only find options on setting the axis title There is a lot of stuff on XY charts on Google but I can't find much on column charts unfortunately .
VB:
'activate sheet and chart
Worksheets("Home Page").Activate
ActiveSheet.ChartObjects("Histogram").Activate
'set variables for chart
With ActiveChart
[Code] .....
I'm trying to meet set criteria in b5 using AND the first works if both conditions are met in two cells but bur won't on one cell?
Private Sub PTIColours_Click()
If Range("b5") > 0 And Range("c5") < 0.149 Then
Range("a5").Interior.ColorIndex = 54
End If
End Sub
But this dosen't
Private Sub PTIColours_Click()
If Range("b5") > 0 And Range("b5") < 0.149 Then
Range("a5").Interior.ColorIndex = 54
End If
End Sub
I have tried searching for a good example of how to use logical operators on Mr Excel however the search is frustrated by "Small Words" in the search field ie IF, AND, NOT ,OR are too short to search.
Can anyone list the formulas needed in Excel
+
_
x
divide
If UCase(TextBox1.Value & "," & TextBox6.Value) < UCase(currsheetname)
This works most of the time, but for something like:
Smith,Bob < Smith,Jim it will give erratic results. currsheetname is not declared so is a variant I guess.
I am trying to write some code that will repair errors in a standard workbook. One of the errors is a blank cell that needs to be changed to "325¨¬F ¡Â T ¡Â 350¨¬F". How do I insert these symbols/operators into the VBA code?
View 6 Replies View RelatedI am trying to alter the type of operator used in one formula based on the result of an argument in a separate cell generally as follows: If Cell 1 equals something then use the ">" operator, otherwise use the "=" operator. I appreciate this sounds really simple and I'm having a major brain fade as I cannot figure out how to relate the two arguments as follows: [If(Value 1 "Operator" Value2, then do something, otherwise do something else)] where the operator is pre-defined in another formula.
View 4 Replies View RelatedI'm trying to figure out how to reorganize data based on boolean values in two different columns. My goal is to write something in VBA that will look to see if the boolean in the first cloumn is true then procede to check if the boolean in the next column, same row is true. If that is the case, it will take several values from the row and move them to another worksheet. If the boolean in the first column is true, but the second column is not, it will look down the rows of the second column until it finds true then move several values from rows it has passed through. Here is an example of the sample data I will be dealing with.
Date Time Duration Boolean1 Boolean2
6/22/200715:0032TRUETRUE
6/22/200718:0058TRUEFALSE
6/22/200719:0060FALSEFALSE
6/22/200720:0060FALSEFALSE
6/22/200721:0060FALSEFALSE
6/22/200722:0060FALSEFALSE
6/22/200723:001 FALSETRUE
Based on the example data my goal is to move the data in a new worksheet that would look something like this
Date Start End Duration
6/22/2007 15:28 16:00 32
6/22/2007 18:02 23:01 299
I have Three different combinations which are in cell A & B, These combinations are with similar signs as in A1=2- & B1 = 2- (& A1 = 2+, B1=2+). Then I have numbers with no signs which A1 =2 B1= 2. My approach is to limit to these and these combinations only and use a formula which is uniformally applied on these combination. I want A1 and B1 to take only like signs like -- or ++ or without any sign. The rest shd be ignored. IS there a way of sorting two columns which have different combinations liek -- or ++ or -+ into a area where u can apply a particular formula? Hence first i take a number and move signs on the left and then apply this
IF A7 = 2- . B7 = 3- THEN
IF(OR(RIGHT(TRIM(B7),1)="-",RIGHT(TRIM(B7),1)=" ",RIGHT(TRIM(B7),1)="+"),LEFT(TRIM(B7),LEN(TRIM(B7))-1)*3,B7*3)
I have two rows of data, each row also have similar data. I need to find the number of matches that the two lines For example :
7,7,K,A,8,7
K,6,7,7,A,9
To reach the conclusion I need to build six such functions:
=1*(COUNTIF($A$65:$F$65,A66)>=COUNTIF($A66:A66,A66))
=1*(COUNTIF($A$65:$F$65,B66)>=COUNTIF($A66:B66,B66))
=1*(COUNTIF($A$65:$F$65,C66)>=COUNTIF($A66:C66,C66))
=1*(COUNTIF($A$65:$F$65,D66)>=COUNTIF($A66:D66,D66))
=1*(COUNTIF($A$65:$F$65,E66)>=COUNTIF($A66:E66,E66))
=1*(COUNTIF($A$65:$F$65,F66)>=COUNTIF($A66:F66,F66))
The result is 4
Is there a single formula that will give the result ?
Another question, is there a formula that I can compare to the principle of one line against the 20 lines ?
Compare 2 columns of data and have a new 3th column tell me the result of the query based on some conditional information. So, here's an example.
Column A = Programmer Assigned (Yes/No)
Column B = Project State (concept, plan, develop, qualify, rollout, etc)
I'd like to compare the values in A to B and have the formula tell me if the programmer should be assigned in that phase or not. So, in english.
If A = No, then look to see if B = "develop" or "qualify", if it does, populate C with "Update required". If it doesn't, populate with "Correct".
I hope I explained it well enough for you all to help. I originally looked into using conditional formatting to just format the cell differently if I needed to perform an action.
to compare the values of data on one sheet (sheet1) with that of another (sheet2) to see if there has been any changes between the sheets over the previous week. If a macro could go through my data on sheet1, compare cell-by-cell the data that's in sheet 2 and highlight in red font any cells that have different values that would be awesome.
The macro would need to leave the "fill color" of the cell as it was.
I have two spreadsheets, The spreadsheet #1 has the information of two years and the Spreadsheet #2 is a montly report. The Spreadsheet # 1 hasta on the column A a number of transaction, and at the column Q the invoice number. The Spreadsheet # 2, only has in the column A the Invoice number. I need to find in the Spreadsheet # 1 the Invoice numbers that match the Invoices that I have in the Spreadsheet # 2 by bringin the "Number of Transaction".
For example:
Spreadsheet 1:
Has on column A3 the Number of Transaction # 0123, and at the column Q3 the Invoice number 555. At the Spreadsheet number # 2 I have the INvoice # 555 located on A10. I need to know what is the transaction # by adding a formula in a new column (G) so I want to have the Transaction # 0123 in the new column added G.
If I do this manually it will take me hours since these report and the Master is so big, and right now I am doin it using Ctrl-F
I have two columns of dates. I want to see if there are duplicate dates and highlight them in the first column. What is the easiest way to do this?
View 9 Replies View RelatedThere are four lines of numbers, in all line 8 numbers.
1 1 2 2 3 1 1 2
1 2 3 1 2 2 2 1
2 1 1 3 1 3 1 2
1 2 2 2 3 1 1 2
I would like to find a function that will examine, if there are similar lines according to my definition, and several.
my definition is 7
For example that I gave, the result in the wanted function needs to be, yes (Line 1 and line 4) and several-One time.
How in VBA can you evaluate a cell in the "general" format and in the "date" format? I'd perfer do this entirely in VBA without use of a helper column in Excel.
View 9 Replies View RelatedI have two columns of items that need to be compaired. What I need is the items in column B that do not match any of the items in column A need to be put in Column C. How can I do this? The Data in Column A can not be re arranged. Column B can be sorted.
View 9 Replies View RelatedI am trying to compare two cells to see if its two values are the same. Some of the cells have a space in between numbers or a symbol like "-"
Ex.
one cell's value is
1213180IN
and the other cell's value is
1213180-IN
the program I have written marks these as different because of the "-" in the second cell....is there a way, maybe with a string function to overlook that "-"?
I have a spreadsheet and I'm comparing data from a room booking system and a spot check on the room to see whether it's actually used. I have a column which I want to show whether the information agrees.
column G - I have a group size recorded that should be in a room.
column H - I have "yes" or "no" as to whether there was anyone in the room when it was checked
column I - I have the size of the actual group in the room.
Is it possible to create a formula that will fill in column J with the answer yes or no depending on whether it agrees.
It doesn't matter whether the groups sizes match, it's just a case of yes, someone was booked into the room and there was someone in when it was checked
OR
No, there was a booking supposed to be in the room but there was no one in it when checked
OR
There was no booking but there was someone in the room when checked.
I need to compare the MMDD in two cells. Example: If the Accrual date is 09/07/10, then I need to know if it falls in the payroll period date of 01/12/12. I just need the MMDD compare to put in my IF statement.
View 1 Replies View RelatedI have two tabs in a workbook. Each has a column containing a unique numerical identifier. What I want to do is create a macro that will loop through the column on tabA, verify it against the column on tabB and when a match occurs delete the row on tabA. The end result should be that only the new items on tabA will remain. Let me know if this is sufficiently clear or still a bit vague.
View 9 Replies View RelatedI am writing some code to do a comparison between two cells X2 or AB2 with an X which checks to:
1. make sure one of the two are filled, or
2. both are not filled.
Below is an extract of the spreadsheet I am working on. I need to check to make sure one of the boxes is checked. If both are empty or both filled with an ("X"), I want a message box to tell me to correct the error and stop the macro from continuing. If only one is marked with an ("X"), I want the macro to continue but don't know how.
RSTUVWXYZAAAB
2IN PROGRESS: COMPLETED:
I have to do monthly comparisons of two excel worksheets, one being a vessel timesheet and the other being an excel download from manpower software that we use. The comparison that is being made are days of the month, whilst the unique identifier between the two sheets (To make it easier to understand I will call them sheet1 and sheet2) is an employee ID. Both sheets, alongside the name and employee ID, list all the days of the month that employees have worked. If they have worked, there is a "1" under that day, if they have not the cell is blank.
What I currently do manually is:
1: Search for the employee ID (and/or name) in sheet1 and compare the days with the employee ID in sheet2.
2: Highlight the differences
3: Move onto the next employee ID
All differences are highlighted in sheet2. Differences highlighted are in the days only, where if any days are missing/extra in either sheet, then the particular cell(s) are highlighted in yellow. If an employee is missing from sheet1 but is in sheet2, then all the days are highlighted (in sheet2). If an employee is missing from sheet2 but is in sheet1, then that particular employee is copied to the bottom of sheet2 (after last row).
As this is horribly complicated to explain, I can attach an example if this is sounding rather inexplicable? Is it possible to attach a xls to a thread?
I am constructing a spreadsheet which is intended to highlight Just in time and late jobs. I have headings job number/Customer/Delivery Date/ Revised Manufacture Date. The first three are already populated by extracting data from our erp system and we enter the revised run date ourselves.
What I am looking for is a formula which shows if the revised run date entry is a day prior to the delivery date then populate the last cell with JIT and colour the cell yellow. Or if the revised run date entry matches or is beyond the delivery date, populate the last cell with LATE and colour the cell red.
With a set of data in colums by quarter and department names in by row I need to answer build a formula that answers simple questions like "what department had the fewest sick days per quarter?" and which department had the most sick days per quarter?"
View 4 Replies View RelatedCan you use a variable as an operator? For example:
Dim op
op = ">"
If Var1 op Var2 Then MsgBox "It Works!"
I have parameters stored in a database and each parameter includes an operator. When I compare a given value to the parameter, I was hoping to do that dynamically by extracting the operator from the parameter and using that in the comparison.
Otherwise, the only way I can see to do it is create a Function with a Select Case list for all the operators to check the parameter, do the comparison, then return the value to the Function.
I have an issue in comparing 2 dates. It gives a data type mismatch error
Private Sub TextBox12_Click()
Dim siebApp As SiebelWebApplication
Dim siebBusObj As SiebelBusObject
Dim revBC As SiebelBusComp
Dim isRecord As Boolean
Dim sRep As String
Dim sCompany As String
Dim sLocation As String
Dim sStep As String
Dim sProb As String
Dim sDate As String
Dim CurDate As Date
Dim RetDate As Date
Dim datmins As Integer
CurDate = Now()
Const DateCol = 9
RetDate = ThisWorkbook. Sheets("Users"). Cells(DateCol)
r = ThisWorkbook.Sheets("Users").Cells(65536, 1).End(xlUp).Row 'Get next blank row
ThisWorkbook.Sheets("Users").Cells(r, DateCol) = CurDate....................
I have highlighted in bold where i do the date comparison. Here are the date formats [Last Updated] = 2002-11-08 13:19:03.000
[RetDate] = 2/13/2008 15:59:18