Assigning Label Names Based On A Range Of Cell Values
Feb 20, 2007
I searched and found that to assign a name to a label based on a cell value requires the following
Label1.Caption = Worksheets("Sheet1").Range("A1").Value
which would assign the value in cell A1 as the caption for Label1. I've got a range of values in cells:
C4:N4
and I'd like to assign them as names to labels 1 through 12. How would I do that using VBA?
View 6 Replies
ADVERTISEMENT
Dec 13, 2013
I could really use some excel function. Within my office, we work with several hundred files. Each employee is assigned files based on the last two digits of the file number. What I need is a way to identify what file is assigned to which employee based on the term digits of the file.
So for example, I have the following list of files:
1002856101
22781721
1044863815
1008799064
1044779765
1006511115
1007641804
0729939256
5303486020
8364709
0014094759
0019921519
8172717
I'm able to do a formula to get the term digits (meaning the last two numbers), but i'd like to have another column that can put names based on the term digit column. For example, Tom might work 00-04, Sally works 05-09, Greg works 10-15, Lucy works 16-21.. etc
I came across the below IF formula that is exactly what i need, except it only works for two associates and not the multiple that i need.. but it looks to be a good starting point nonetheless.
------------------------------
=IF(C2<50,"Sheryl","Lisa"). You should enclose Sheryl and Lisa with quotation marks as these are string values.
You can also use (if A2 is where the Loan # is):
=IF(Right(A2,2)*1<50,"Sheryl","Lisa")
The formula will acquire the last 2 digits of the loan and check it if it's for Sheryl's or Lisa's.
-----------------------------
View 3 Replies
View Related
Feb 19, 2010
I have two tables below. First table contains the list of domain names (given just for example, actual list may contain several more such Domain names) with the group names assigned to them. Second table shows the criteria for assigning them the group names:
Sheet2ABCDEFG1Table 1Table 22Domain NameGroup NameDomain NameGroup NameDomain NameGroup Name3NCG-W3K-SAT14-0DOSSNCG-W3K-EEC-SUN16-3EECEXCEEC4SVL-WIN-SAT08-0LABSNCG-W3K-SUN16-0DOSSDCDC5SVL-WIN-SAT06-0LABSNCG-W3K-TUE01-0DOSSNCGDOSS6NCG-W3K-MON04-0DOSSNCG-WIN-EXC-SUN21-0EECDMZETIS7NCG-W3K-EXC-MON04-3EECNCG-WIN-EXC-SAT16-0EECSVLLABS8NCG-W3K-EXC-MON03-0EECNCG-W3K-X64-DC-SAT14-0DC9NCG-W3K-EXC-TUE01-0EECDMZ-NCG-W3K-X64-SUN12-0ETIS10NCG-W3K-EXC-SUN15-0EECDMZ-NCG-W2K-SUN12-0ETIS11NCG-W3K-X64-EXC-SUN16-0EECNCG-W2K-SUN20-0DOSS12DMZ-NCG-W3K-SUN11-0ETISNCG-W3K-MON03-3DOSS13NCG-W2K-DC-SUN11-3DCSVL-DMZ-WIN-SUN12-3LABS14NCG-W3K-X64-DC-SUN10-3DCSVL-DMZ-WIN-SAT10-0LABS15SVL-DMZ-W2K-SUN12-3LABSDMZ-NCG-W3K-SUN12-0ETIS16NCG-W3K-EXC2-MON03-3EECDMZ-NCG-W3K-SUN10-0ETIS17NCG-W2K-SAT17-0DOSSNCG-W8K-X64-DC-SUN10-4DC18NCG-W3K-X64-SUN10-0DOSSNCG-W3K-TUE01-3DOSS19NCG-W3K-TUE00-0DOSSNCG-W3K-DC-TUE02-0DC20NCG-W3K-X64-SAT15-0DOSSSVL-WIN-SAT11-0LABS21NCG-W3K-WED00-0DOSSSVL-WIN-SAT07-0LABS22NCG-W8K-X64-SUN19-0DOSSNCG-W2K-SUN17-0DOSS23NCG-W3K-EXC-SUN20-0EECNCG-W3K-SUN20-0DOSS24NCG-W3K-ULZ-SUN14-0DOSSNCG-W3K-TUE22-0DOSS25NCG-W3K-TUE03-0DOSSSVL-WIN-SAT07-3LABS26NCG-W3K-ULZ-TUE00-0DOSSNCG-W3K-MON05-3DOSS27NCG-W3K-SUN19-0DOSSNCG-W8K-SUN18-3DOSS28NCG-W3K-EEC-SUN19-0EECNCG-W8K-SUN22-0DOSS29NCG-W3K-EEC-SUN20-3EECNCG-W8K-X64-DC-SUN11-0DC30NCG-W3K-EEC-THU00-0EECNCG-W3K-SUN17-0DOSSExcel 2007
My concern is to automate this process using a VBA code. How can I search for the keyword given in Table 2 in the first column of Table 1 and assign the group names as it is assigned currently, considering the below conditions and criteria.
1) The correct group name should be assigned to the Domain name containing the keyword given as per criteria in Table 2
2) It is possible that the domain name will include more than one keywords given in Table 2. For example Cell number A7 contains both keywords NCG and EXC, in such cases the preferance should be given to EXC and we will assign the group name as EEC. And in Cell number A12 also contains both NCG and DMZ, again the preferance should be given to DMZ and we have to assign group name as ETIS.
That means we will give second preference to keyword NCG. If domain name contains none of the keywords except NCG as per given criteria then only we will assign grup name DOSS.
View 9 Replies
View Related
Jan 30, 2014
Cell A1: can contain any number between 1 and 4 (with two decimal places, i.e. 2.36 or 3.99)
Cell A2: based on what number is in A1, this field should return corresponding percentage (%), based on the following criteria:
1: is 100%
2.99: 1%
3 (including) and less (all the way to 4): 0%
Note: percentages between values 1 and 2.99 are equally spread
So let's say, when:
A1 is 1.00, then A2 should return 100%
A1 is 3.26, then A2 should return 0%
A1: is 1.25, then A2 should return 92% (or whatever percentage is correct based on above described criteria)
View 3 Replies
View Related
Jun 15, 2008
i have a table in excel with 36 rows and 36 columns i.e. 36x36=1296 individual cells. Columns and rows have headers/labels i.e. 36 rows with row label headings and similarly 36 columns with column label headings. I would like to automatically create unique cell names for the 1296 cells based on where the columns and rows intersect using the row and column labels. The cell name format I would like to create is [ColumnLabel_RowLabel].
I've manually created the cell names in the attached file as an example of what i would am seeking (i've greyed the cells that I've done this for).
View 9 Replies
View Related
Dec 1, 2013
I have a column with names (repeated names by month). There are about 3700 of them spread over 12 month. so it's about 300 names per month.
Is it possible to assign an ID (a number) to specific names?
So let's say - John Smith will have ID 1 (for example), and will always get this ID?
View 8 Replies
View Related
May 5, 2008
I have a number of cells which are connected to various formulas. EX. A1 = 7. Well I want a formula in A2 which can look at A1 and if A1 = 5-6, then A2 = 1, if A1 = 7-8, then A2 =2, if A1 = 9-10, then A2 = 3, if A1 = 11-12, then A2 = 4. And so on.
View 11 Replies
View Related
Jun 6, 2014
How to assign a "WS(i)" worksheet name and have the assigned variable (i) in the name equal the consecutive steps in a total page count.
Here's the code that does not work:
Code:
Dim WB as Workbook
Dim WS as Worksheet
Set WB = ThisWorkbook
For i = 1 To WB.Sheets.Count
Set WS(i) = WB.Sheets(i)
Next
I can see why it does not work. I can't figure out what to declare in my Dim or how to word the statement using the (i) variable in order to capture the value to attach to "WS."
Details: The issue is that the number of pages created will vary day to day depending on staff needs. There's an array of staff names to be assigned to page tabs and there will be skips and deletions along the way depending on daily attendance so "WS(i)" worksheet names can't be assigned at creation. What happens if they are is that the succession of worksheet names winds up being (e.g.) "WS1, WS2, WS5, WS12," etc. instead of consecutive.
There's a very complex data-sort-and-assign system that depends upon how many staff-assigned sheets there are, and as such each sheet has to have a "WS" worksheet name for the process to stay smooth. If the names are not consecutive, though, the sort-and-assign process becomes confused. This step takes place at the end of the initial workbook set up process, immediately before the data are addressed, so there really isn't an earlier opportunity. It can't be later since from this point on the system depends upon the "WS(i)" names being there.
It started fine when there were 5 people. Now there are 37.
View 2 Replies
View Related
Aug 31, 2012
I want to build a database where the user can select a specific time period. I have a static file with the time periods and the related values. For instance I have in column A1:A15 the time periods from January 2011 to Dezember 2011, but I have some dates multiple times as there are more values attached to it. For instance I have in the first 4 rows January 2011...what I want is when someone puts in the value January 2011 in cell B1 and Dezember 2011 in cell B2 that the whole static file gets copied to another location (including the multiple dates) displaying the chosen time period. Similarly if someone puts in the value March 2011 to November 2011, I want only those values to be copied.
View 4 Replies
View Related
Sep 17, 2013
I am working on a customer report template that generates our customers reports and will send them out automatically.
This issue I have now is that the system that generates the raw data for these reports only lists the Customers name in a column with an entry for each line of data, the thing is though that the system has lots of variations of the customers name, even more so if that customers has different departments.
What I need to do is from this list of customer names, I need to automatically figure out what the "common" name is or main name so to speak, and then make a variable using the correct full name, which will be used later on in the code to import correct logos, and direct the reports to the correct people.
Here is a quick example of what data we get raw from the system:
Customer Name:
John Build
Johns Buildings
Johns Ltd Building
Johns Plumbing Department
Glass Doors Ltd A Department of Johns Buildings
Johns Building Corporation
Hole In One Golf Range
This is just an example, we have thousands of clients, so the length, number of words etc can change alot. Ideally I from a list similar to that I would get a full proper result of "Johns Buildings Ltd" for example, this would then be in a variable to be used in code from then on to reference doing certain things with the reports of Johns Buildings Ltd.
You'll notice there is one name "Hole In One Golf Range" that seems to have no relation at all, this is correct, ideally I would also like to build in some error checking into the code, so that rows like that that have nothing to do with the others would get deleted.
So how would you amazing VBA gurus go about working with data like this? I'd prefer a more general answer with explainations that just straight code, as I'm sure I will have to adapt the hell out of it for it to be useful in context.
View 9 Replies
View Related
Mar 18, 2011
Is there any way to change a label in a user form based on the value of a cell?
I'm trying to link a series of labels to a small range of cells that change based on a data-validation drop box.
I've tried finding info, but I can't seem to find the right place.
The code I've tried so far without result is:
Code:
Private Sub Label3_Click()
Me.Label13.Caption = ActiveSheet.Range("BQ15")
End Sub
View 9 Replies
View Related
Feb 13, 2008
I'm working for a local authority who have been given a mass of survey data. In this particular task, residents of each small district within our area have been asked their levels of satisfaction with a service, and how important they think that service is. I want to plot these two values against each other using a scatterplot, and label each service.
Excel does not automatically allow this so I used a very good sheet from the forums here: Attach labels with names to the points in a scatter plot. It's the top file, and works well. However, I can't seem to customise it for my own data.
Problems include:
- Excel often freezing when I try to run it
- Not all the data being picked up for the chart
- Incorrect labels being picked up..........
View 4 Replies
View Related
Nov 28, 2012
I am trying to put together a calculation sheet for court costs and I need a cell to return a value based on the amount entered in another cell. For example, if I input a value between 1 and 5 in cell A1, I would like "Cat" to appear in cell A2. However, if I input a value between 6 and 10 in cell A1, I would like "Dog" to appear in cell A2. Is this something that can be done without VB?
For the real spreadsheet, I would need the following outputs in cell A2 based on the respective ranges in cell A1:
Output to A2 = $405 if input to A1 is < $50,000.
Output to A2 = $905 if input to A1 is ≥ $50,000 and < $250,000
Output to A2 = $1,905 if input to A1 is ≥ $250,000
View 3 Replies
View Related
Feb 5, 2013
I've attached a workbook to explain my query further but essentially I have a data range, variable in size and I would like to split the range based on values in the range (delimiters if you like) into discreet ranges.
RanaldRangeSplit_01.xlsx
View 6 Replies
View Related
Jan 24, 2009
In my workbook sheet 11 has some ranges that need to have names based on cell values in sheet2 (for purposes of data validation lists).
Range S28:S46 will assume the name of sheet2A11 & sheet2A3.
(example name period_1unit_1)
Range U28:U46 will assume the name of sheet2A11 & sheet2A4.
Range W28:W46 will assume the name of sheet2A11 & sheet2A5
Right now I am calling the code when something is entered into A11.
I have tried if statement and select case, but I ran into complications with both.
I have posted both codes with the questions I have concerning those codes.
View 6 Replies
View Related
Feb 13, 2008
I have a range "RangeOne" and i want to check the range row by row.
In each row I want to check for value in second cell. If the value is 10 or more then the entire row in the range should be selected and then execute a macro. If the value is 0 to 10(but not 10 exactly) then the row in the range should be selected and then execute macro2.
View 3 Replies
View Related
Feb 4, 2010
How can I sum values with names based on a number prefix? For example, in the attached sheet, how can i sum all values that have the prefix 4.10.02.xxxx?
View 2 Replies
View Related
Aug 2, 2012
I'm new to excel and was trying to make a workbook that will have a drop down list populate based on a user input in two separate cells. Basically, i have columns: name, pages, and books. I would like to have the drop down list match data by first finding the amount of books read, then finding the amount of pages read. Then any name that meets the criteria will be available in the drop down list. How can I do this?
View 1 Replies
View Related
Aug 13, 2014
I've been trying to put together some code to hide a range of rows on one page based on cell values on a different page. So basically Sheet1 cell A1 value is 10, A2 value is 20. When macro is run via button rows on Sheet2 from 10-20 would be hidden. The issue is the values in the cells on Sheet1 will vary. I thought something like the following would work but it doesn't.
[Code] ....
View 6 Replies
View Related
Jun 6, 2012
I have two rows of numbers, say D1 to F1 and D2 to F2. Row D2 to F2 will always have lower values.
The range below it is D3 to F100. I want the range to clear the contents of the cells in the range where:
a) the cell is > the x1 cell above it
OR b) the cell is < the x2 cell above it
If it is = or between the two cells, the value stays.
Example:
If D1 thru F1 is 4, 5, 7 and D2 thru F2 is 2, 4, 3, then:
D3 is 5, it is cleared
E3 is 4, it stays
F3 is 5, it stays
D4 is 2, it stays
E4 is 1, it is cleared
F4 is 9, it is cleared
Etc
Basically, the cell in the range looks up its own column, compares itself to x1 and x2 in that column. If it's greater than or less than, then it clears the contents, if not, the value in the cell stays.
View 3 Replies
View Related
Jul 30, 2014
I have a range of cells where each row relates to an employee.
In Cells (Columns H:L) I want the range of cells on that row to turn blue if the user puts a "H" in one of the cells.
Also it will need to be adapted for "O" , "Y", "X" - each with different colours.
This needs to be repeated on each row for each person.
View 5 Replies
View Related
Aug 5, 2008
I want to make several charts with dynamic ranges. To do that, I wrote the offset functions I need in cells. I've attached a sample spreadsheet. I want to have a macro so that when I run it, it will take the contents of the active cell, insert a name called those contents, and make it refer to the cell 4 to the left of it.
In the spreadsheet, I'd like to be able to click on E2 (sentdate1), create a name called sentdate1, and make its value A2, or =OFFSET('Sentiment'!$A$3,0,0,COUNT('Sentiment'!$A:$A),1). Here's what I have so far.
Sub Macro8()
ActiveCell.Offset(0, -4).Range("A1").Select
ActiveCell.Offset(0, 4).Range("A1").Select
ActiveWorkbook.Names.Add Name:="sentdate1", RefersToR1C1:= _
"=OFFSET(Sentiment!R3C1,0,0,COUNT(Sentiment!C1),1)"
End Sub
Auto Merged Post Until 24 Hrs Passes;Here's the sample worksheet.
View 6 Replies
View Related
Jan 23, 2013
I have recorded a macro to sort a range of cell based on two values that is dependent on time in another cell. I now want the macro to run automatically when refreshing the workbook with F9, so as the time changes so will the sorting. Everything works fine except the sorting doesn't refresh when F9 is refreshed.
My recorded macro is:
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, FillCT As Long
For X = 1 To 4
If Cells(Rows.count, 1).End(xlUp).Offset(0, X - 1) <> "" Then FillCT = FillCT + 1
[Code] .....
View 4 Replies
View Related
Mar 31, 2014
So I have 2 sheets from a much larger worksheet where I wish for the first sheet to extract a row of values, one at a time from the second sheet using a range of numbers I enter as reference for where to look for the data. Sheet 1 can be thought of as a summary page and Sheet 2 is where data is stored.
I need to first check if any data under Sheet 2 column B fall within a specified range of numbers and if any of those numbers are found I want it to grab the largest and latest number from that range and pull all the data from certain columns in that same row and place it into Sheet 1, one column value at a time.
Sheet 1 A1 = A range of numbers as text. 10-15, 16-20 etc Only one range is entered. This also tells me what results I'm looking at.
Sheet 1 B4:B14 = Destination cells for the individual data I'm wanting to pull from Sheet 2 columns H:P. B4 wants H, B5 wants I, B6 wants J etc
Sheet 2 column A = A3:A102 are numbered 1:100.
Sheet 2 column B = A series of numbers anywhere from 10-70. Always in sequence and they can repeat. 10,10,11,12,13,14,15,15,15,16 etc. Ranges from B3:B102. Only one number per cell.
Sheet 2 columns H:P = Data in H3:P102 I want to extract to Sheet 1 B4:B14.
Now lets say I want a formula for Sheet 1 B4 which wants a value in Sheet 2 H. If Sheet 1 A1 = 10-15, I want to check whether Sheet 2 column B has any values equaling those and then tell me which row that last number appeared in.
Example: Sheet 2 B4=14, Sheet 2 B5=14, Sheet 2 B6=16. Use B5. (B6 is outside range and B4 isn't the last time the 14 appears.)
Then, knowing B5 is the value I want, find which row it is in (row 5 in this example) or use the number in A5 (3) and then find my way to column H (H5) where the value I want to pull is.
Example 2: Sheet 2 B4=14, Sheet 2 B5=14, Sheet 2 B6=16. Use B5.
Sheet 2 H4=10, Sheet 2 H5=32, Sheet 2 H6=42. Place "32" from H5 into Sheet 1 B4.
I'd like to also have some error control so I'm not trying to pull data from blank cells if it's relevant. Maybe check if Sheet 2 X3=0 and if it is, do nothing as no data appears if the cell is 0.
I have put a lot of time into trying to solve this myself but I feel way out of my depth. I've tried going step by step but I can't seem to figure out which functions are relevant and also things like how to return the range that the A1 values appear in or if using MAX, not having it return values outside of A1's range also.
View 7 Replies
View Related
Oct 24, 2013
I would like to format the color of cell A1 on Sheet 1 based on true or false values from cell range A1:A10 on sheet 2. For instance:
1. If all cells on sheet 2 in range A1:A10 were false then cell A1 on sheet 1 would be red.
2. If some cells on sheet 2 in the range A1:A10 were false and some were true then cell A1 on sheet 1 would be yellow.
3. If all cells on sheet 2 in range A1:A10 were true then cell A1 on sheet 1 would be green.
View 5 Replies
View Related
Oct 2, 2011
How to change the background cell color based on value ranges(s)
I tried conditional formatting but it works between two values only, in my assignment I want to show:
River levels in relation to flood class
>=2m =2.6 =3m major flood (background turns red)
I hope it is possible in Office 2007
View 9 Replies
View Related
Mar 17, 2014
Please see attached sample worksheet. Column A will be generated by the user manually.
I'm looking for a way in VBA to have A1:D20 in Sheet2 copied and pasted in the "Bank Reconciliation" Sheet based on how many "Markets" there are in Column A. Then, once that's complete to have A22:D30 (the smaller box in Sheet2) copied and pasted directly below those results.
I have what the macro would hopefully generate to the right in "Bank Reconciliation" (B6:E54) as an example. So if there's a market in A1, copy and paste the box to B6. If there's a market in A2, copy and paste the box directly below the first (B26) etc. etc. until it's done, then paste the smaller box directly below whatever the macro generates.
Book2.xlsx
View 3 Replies
View Related
Jan 4, 2013
Essentially, I'm arranging an excel spreadsheet to organise my ongoing sales and keep record. I would love to have a formula to calculate the appropriate comission for each sale.
The ranges are:
0-199 = 0 Comission
200-499 = 10 Comission
500-999 = 25 Comission
1000+ = 50 Comission
I managed to get the 0, 10 Comission to be processed correctly but sadly I've hit a brick wall as to how to include the 25, 50.
The formula I have so far is as follow: =IF(COUNT(D22),IF(D22
View 2 Replies
View Related
Jan 24, 2014
I have to assign 3 values to 3 letters, I have been using the LOOKUP function,
P=20, C=35, W=100
I have input the following:-
=LOOKUP(A1,{"P","C","W"},{20,35,100})
But for some reason it is inputting 35 for the value of P.
View 3 Replies
View Related
Apr 30, 2007
I am trying to assign a range of values with different types( date,time,integer) to an array. I am using the following command which works fine.
Dim vArr() As Variant
vArr=range("A1"). currentregion.value
However when I try to print the "time formatted" values in the second column of the range I can't. I can't use timevalue function as well cause it doesn't treat the values as string but integers. Why is this happening even when I declare the array as variant?
View 2 Replies
View Related