VBA To Assign Value From Certain Text Other Value Ranges

Aug 22, 2012

I have a series of values in one worksheet across one row. The row contains "Yes" or "No" text and also some currency or other number values.

My spreadsheet looks like this (the blank shown is a cell that has no value or text):

Yes No Yes No (blank) Yes No $100 50% 5

What I'd like to do is to have a VBA code that assigns a value to each of these text and numerical values by the following criteria:

If Yes, Value = 0
If No, Value = 5
If "Blank", Value = 0
If $0 to $25, Value = 1

[Code] ........

Therefore, I want to have the outputs in another worksheet (sheet 2) and it should show the following numbers based on the criteria above:

0 5 0 5 0 0 5 4 2 1

View 1 Replies


ADVERTISEMENT

Would Like To Assign Ranges For Each Row

Apr 5, 2009

I am defining ranges for cells in a row by the formula:
Set myrange3 = Range("B13", Cells(13, Columns.Count).End(xlToLeft))
Set myrange4 = Range("B14", Cells(14, Columns.Count).End(xlToLeft))
Set myrange5 = Range("B15", Cells(15, Columns.Count).End(xlToLeft))
Set myrange6 = Range("B16", Cells(16, Columns.Count).End(xlToLeft))
Set myrange7 = Range("B17", Cells(17, Columns.Count).End(xlToLeft))
.
.
.
.
.
Set myrange62 = Range("B72", Cells(72, Columns.Count).End(xlToLeft))

The last one is 62 assuming data wont go over 62nd line. However, there would be always a room for error if this is done manually. Is there any way, I could assign range variables only till that row which has data

For example
The data below shows I only need to define range variables namely myrange1 including cells 2 and 5 till myrange7 of cell values 9 and 6.

A B
2 5
3.4 8
5 12
6 23
77 56
8 7
9 6

The syntax:
LastRow = Selection.SpecialCells(xlCellTypeLastCell).Row helps by giving the number of the last valid data row, but I am not sure how this might be used if at all in automatically assigning ranges of valid row cells to variables.

View 9 Replies View Related

Assign A Value To Text

Sep 22, 2005

I have read a lot of posts, and maybe I am way out of my leage.

I am trying to setup a spreed sheet for our fire department.

We want to create a way to track training pay. When someone attends the
training we want to just put an "x" in next to their name in the column for
that training event rather then 9.75 for example. But we also want to be able
to add up all training for that individual for the year and see what we paid
them.

The idea is we have a sheet that shows us checks of who attended and who
did not. But we also want to add up the pay associated with that x.

So:
We want column A to be member names

Column B is a training event.

We want to go down and put in an "X" for each member who attended.

Now What I want is to have that "x" be associated with a dollar value. For
example lets say that they get $10 for that training.

THe idea is that I can run a total at the end of the year for each member
for each "x" and see how much money they recieved. I.E. the "x" is a hidden
value maybe that when I add up all the "x"s for a member it will give me
total dolar value for all training they attended.

View 9 Replies View Related

Assign Text To A Value?

May 29, 2012

I want to assign a text to a value. e.g if i have 2, it should come up as negative.

View 9 Replies View Related

Assign Number To Text

Jan 23, 2014

I currently have a spreadsheet which I use to do an audit of the office stationery supplies.

There 3 columns at the focus of this question:

F - Number of items in stock
H - Stock re-ordering level
I - Order Required

I currently have an IF statement to tell me if I need to re-order any stock, by comparing the Number of items in stock against Stock Re-ordering level.

The statement is =IF(H1>=F1, "Yes","No")

This works fine under most circumstances. However, in some of the H cells, I have the text "Special" which indicates that the stock will only need re-ordering on a special occasion.

Any value I enter in F will cause the I to say "Yes".

Is there any way to make the word "Special" equivalent to 0, so I says "No"?

View 4 Replies View Related

Assign Text Value, Then Count

Nov 10, 2008

First challenge will be assigning point values to Words so I can them up and create averages etc

So I have 4 words I need to learn to assign point vales to, then create a formula that will count the points in a row. That will get me off and running,

So here is a very vague idea of what I mean, this would go in A5 as a example

if A1:D1= complete+2 incomplete+0 submitted+1 missing-1

so if I had a row that was:

Submitted | Submitted |Complete| Complete | Missing | 5

( 5 would be the value the formula would return 1+1+2+2-1)

View 4 Replies View Related

Assign Value To Text Formatted Cell

Dec 30, 2008

I want to be able to "count" apples and oranges. Is there a way to record a particular text in a text formatted cell and count it. e.g. 10 cells, 3 say "apples", three say "oranges", 4 say "plums". I want excel to keep track of the three types of fruit when I change them and give me a running number of each.

View 2 Replies View Related

Assign Text In Data Validation?

Nov 17, 2013

Is it possible to assign text using data validation?

Right now, the three cells I'm using for data validation contain text, but return a number to the linked cell.

View 1 Replies View Related

How To Assign Text From Textbox To A Cell

Sep 3, 2012

I have used a textbox ( not an activeX text box) to get input from user. I want to get that value into a cell.

View 3 Replies View Related

Assign Value If Partial Text Match?

Mar 28, 2013

I have a long list of categories in the column A (seen below). To this list i want to assign keys that will support with further calculations (in a column B).

An example of such a key would be in the case of the given example "ACTION SPORTS" and "FOOTBALL". The whole list of these "keys" hast 17 elements.

It is evident that i will need some kind of a partial match. The one i have found on the internet, limittin itself just on the first or last number of characters wont work.

Would it be possible to select my "key - list" (all 17 of them). Then excel would asign a key, whenver it would find a partial match, matching the key?

Appendix:
The Data list (Column A):
ACTION SPORTS FTW
ACTION SPORTS FTW
ACTION SPORTS FTW
ACTION SPORTS FTW
ACTION SPORTS FTW

[code].....

View 6 Replies View Related

Buttons To Assign Values To A Text Box

Sep 15, 2008

I have an issue with some excel spread sheet I am working on.

I am using Macros, Buttons to assign values to a text box.

When I do not protect the worksheet no problems.

When I include my calculation sub into my Worksheet Change module.
It sort of works but flashes a lot, and takes about 6 or more seconds.

When I dont include it in the Worksheet change module it doesn't flash and seems to work fine.

When I protect the work sheet, in my code I unprotect it and try to run my code, but it wont go through. I get an error.

Run-Time error '1004': Application-defined or object-defined error

Worksheet Module
Option Explicit ' Force the declarations of all variables in this module
Private Sub Worksheet_Change(ByVal Target As Range)
'Unprotect

'Call Calculate_Decision
If Range("MoreBorrowers") = "Yes" Then
Rows("21:27").Hidden = False
Else
Rows("21:27").Hidden = True
End If
If Range("GuaranteeYN") = "Yes" Then
Rows("159:167").Hidden = False
Else
Rows("159:167").Hidden = True
End If

I have tried adding in the Me. before my Range but nothing seems to work.

View 9 Replies View Related

Assign A Number Value To Text Within Worksheet

Sep 10, 2009

I need to count the number of times a value appears in a row and assign a number that tells which occurence of the text it is.
For example

Name Address
Jim 123 Smith Street
Jane 123 Smith Street
Bob 543 Apple Street
Mary 543 Apple Street

I would like a way to insert a column that puts a 1 next to Jim and a 2 next to Jane, a 1 next to Bob and a 2 next to Mary and so on.
Ultimately, I want to sort the list and delete all the twos, thus deleting the duplicate address entry.

View 9 Replies View Related

Assign Numbers To Text Words

Sep 7, 2007

I would like to know if I can do a VBA code that takes one formule that is showed as text in one cell (eg '=wood+plastic) to the next cell to really use it... I mean, that one time we define de "wood" valeu and plastic valeu will realize the calcul.

View 9 Replies View Related

VBA - If Cell Contains Text Within Array In Different Workbook / Assign Value

Oct 20, 2012

I have a worksheet (WORK1) that contains two columns of values that I can add to or change if necessary. The first column would be a text string (STRING), the second column would be its category (CATEGORY).

Example:
STRING CATEGORY
Chevron Gas
Exxon Gas
Vons Groceries
McDonalds Hamburger

In a separate workbook (WORK2), I have a column (A) which contains text. Ex:

A1 = "Station 2134 Chevron Motor"
A2 = "ExxonOil 234"
A3 = "Vons store"
A4 = "Hamburger McDonalds"

I would like to assign B1, B2, and so on... a CATEGORY if it contains STRING.

For this example, B1, B2, and so on... would be assigned the values.

B1 = "Gas"
B2 = "Gas"
B3 = "Groceries"
B4 = "Hamburger"

View 5 Replies View Related

Assign Numerical Values To Text To Allow Calculations

Jan 31, 2010

I am working up a workbook template that will be used to process survey results. The way I ultimatley want it to work is that the user can paste data from another application into a worksheet in Excel, and then view analysed results on a second sheet (which are processed via formulae on a third, hidden sheet).

The problem I have is this: the data from the program that's capturing them are text values. For example, column B contains answers to a question where participants rate an experience, and the values are either "Excellent", "Good", "Fair", "Poor", "Awful". I want these to be converted to numerical values, on a scale where "Excellent" = 5 and "Awful" = 1, so that I can then average these.

So, the question is: Can I somehow tell Excel that "Excellent" = 5 and "Good" = 4 etc, and then use AVERAGE(B:B) on the text data and get a number back?

I did think of having an intermediate sheet that used VLOOKUP to create a copy of the first sheet (where the user pastes the text data) with the text replaced by numbers. But, because I don't know in advance how many rows will contain data (i.e. how many survey results there will be), I have to assume on the high side and copy down 50,000 rows. But, this takes ages to calculate.

View 9 Replies View Related

Formula / Macro To Search Cell Text And Assign Value?

Jan 30, 2014

I am trying to get a code which searches each row for a keyword, and then assigns a value to it depending on what group of keywords it is.

For example, if the Name or Comment mentions certain fruit keywords, I want it to assign the value: "Fruit", and if it mentions certain vegetable keywords, I want to assign it "Vegetables", and if it is unrelated to either, I want to keep it blank. If the name/comment mentions both fruit and vegetables then I want it to say "Error".

Since the keywords I am using are mostly two letters, I want the search to only search for the two letters on its own, and not as part of a sentence. e.g. if the key word is ED, I don't want it to return a value for "I rested". Instead, I want it to stay blank.

i.e. I want the code to take information from column A and B, and assign a value based on the keywords in column D and E. As an example:

A B C
Name Comment Value
V1 Eating vegetables are good for you Vegetable
null lock out of ep. Fruit
S-1 It is JUST
Fruit-sp Error

D E
Fruit Vegetable
EP SW
KG SP
ST CM
BV LP

The formula I used so far is this: where C3 is the first value
C3=IF(OR(ISNUMBER(LOOKUP(100,SEARCH(Sheet1!$D$2:$D$6,A3))),ISNUMBER(LOOKUP(100,SEARCH(Sheet1!$D$2:$D$6,B3)))),"Fruit","")&IF(OR(ISNUMBER(LOOKUP(100,SEARCH(Sheet1!$E$2:$E$6,A3))),ISNUMBER(LOOKUP(100,SEARCH($E$2:$E$6,B3)))),"Vegetable","")

In columns D and E I put a leading and trailing space between each word to only search for the keywords themselves, and not as part of a word. (e.g. ST is correct instead of haSTe).

This formula seems to work only for 60% of the information, problems occur when the keyword is at the end of comment sentence: the value is blank. e.g. in row B4 of the table I made above my formula returns a blank.

View 1 Replies View Related

Assign To A Variable, The Total Number Of Text Entries In Col

Feb 28, 2009

I need to assign to a variable, the total number of text entries in col. A (or alternatively in a named range).

View 5 Replies View Related

Lots Of Text Data, Need To Assign Unique Numeric Values

Aug 28, 2009

Here's my situation.

I will post a rudimentary example:
Account Name/Column A
Truman school, San Diego
Truman school, San Diego
Truman school, San francisco
Truman school, Atlanta
Truman school, Atlanta


In column B, I would like it to assign a unique numeric id based on the TEXT only.

So Truman school, San Diego gets a string of numbers: 1234
Truman school, san fran: 1235
Truman school, Atlanta: 1236

My spreadsheet is about 6,000 records with a great deal of the above situation going on. So school names are identical with different locations assigned. I am trying to import to a database and don't want a lot of duplicate records. That's why I'm trying to assign a numeric value.

View 4 Replies View Related

Write Ranges To Text Files & Save Each As Cell Text

Sep 17, 2007

I m trying to write a macro which could take the text from a single column row T2 to row T313 and write it to a .txt file. Have the .txt file name created by the text in T4 or I could also put the text to name the file in T1 if you think it would be easier.

Then carry on to the next named sheet and produce another .txt file in exactly the same way until all 15 sheets have been completed. It would also be helpful if prior to starting to write each text files, it could test for any text in cell A2 of the sheet. The first empty A2 cell of a sheet would determine the end of the run, if it was prior to sheet 15 being reached.

View 2 Replies View Related

Count A Text In Different Ranges?

Mar 17, 2014

how to count a specific text in two different ranges eg a text "moby" ....want to count how many times it comes in ranges b4:b20 and in b50:b70

View 3 Replies View Related

Querying Text Ranges

Apr 5, 2007

I've been racking my brain for hours over the past few days trying to compile a spreadsheet for work. Currently the spreadsheet covers all the aspects of a auto loan process. It is used as a tool for auditors to check the work of others. The spreadsheet simply uses "P" to designate "Pass" or "F" to designate "Fail" on whichever section.

How do I reference the P's and the F's in the spreadsheet? I've had trouble getting excel to query any text in cells. Also, each loan application is started on the next line, so I need to make sure these formulas repeat as a new line is started - how would I go about doing this? Currently - Cell G3-CG3 contain the "P's" or "F's" - the formula I had used was {=IF(G3<>"P","FAIL","PASS")} - which does work, on a single cell. However, if I try to add the entire range in {=IF(G3:CG3<>"P","FAIL","PASS")} the cell returns #VALUE. Obviously, I'm inexperienced with excel in this fashion, and I need to know what formula I should be using.

View 10 Replies View Related

Number Values Converted To Text, Multiple Ranges.

Mar 9, 2009

I have attached an example sheet to help visually explain what I am going to try and articulate. Cell A2 and B2's values result in cell E2, Cell C2 and D2's values result in cell F2. The same is true for row 3.

So what I would like to do is, based on the predetermined ranges of the Height+Chest Columns, auto complete column E, and Columns C+D, auto complete column F. My problem is that I cannot simply cell A + B = E, because the maximum range of one layers the minumum range of another. An example would be Maximum of A+B is 101 to result in SXS in Columm C, but the minmum A+B to get a SS in column C would be 97. So what I need is, for another specific example:....

If cell A2 is between 57 and 65, and cell B2 is between 31 and 36, then Cell C2 must be SXS. If Cell A2 is between 66 and 68, and Cell B2 is between 31 and 36, then Cell C2 must be SS.

View 5 Replies View Related

Export Ranges To Text File & Import Back

May 14, 2007

I have been copying the work sheet ranges
"Consolidated Data" D4:K17
"Support Schedule" D5:W504
"Tangent Calx1" D4:F34 , J4:J34 and M4:M34
"Tangent Calx2" D4:F34 , J4:J34 and M4:M34
To a seperate worksheet for export to a txt file {for saving}
Then {when required} importing the txt file data into the worksheet ,copy the data back to the worksheet ranges and re-calculating the data. I have struggled to trying and butcher the code and delete the copy stage and write just the required ranges to the txtfile.(And reverse)

View 8 Replies View Related

Move Ranges To Corresponding Ranges Based On Column Having Data

Oct 25, 2007

I need help creating a macro that will search through my excel spreadsheet and for every instance where column A isn't empty it should cut a range of columns from that row and paste them in a different range of columns in the row before it. It should then delete the row that it cut the columns from and keep searching until it has done this for the whole worksheet. I can modify which range of columns are needed, but it has been so long since I've worked with excel macros that I haven't been able to do it.

View 5 Replies View Related

Save Ranges In Multiple Files To Text Files

Dec 21, 2007

I have a excel file that I enter information into. I have code that saves the files to a certain folder with the name, date, and time stamp for the file name. At the end of the day I might have 3 to 15 excel files I have created that day and I would like to take information from certain cells (examle: L3, B6, B7, B8, G8, and so on) and create a txt file with all of the information in it.

Example:
12/20/2007
Your Name
123 Somewhere St.
Here, OH 45111
Home Visit

12/20/2007
Someone Else
345 Anywhere St.
There, OH 45211
Hospital Visit

View 9 Replies View Related

Static Ranges And Dynamic Ranges

Feb 26, 2010

definitions for static ranges and dynamic ranges?

View 9 Replies View Related

2 Input Vertical Ranges Need Formulas To Output 2 Vertical Summary Ranges

Mar 7, 2013

I have two vertical ranges that I need summarized into 2 adjacent vertical ranges.

"
A B C D
| SUMMARY
model qty| modelqty
1 4.12922.0000| 4.12952.2000
2 2.000012.1250| 2.000025.1250
3 4.12929.0000| 318.0000
4 318.0000|
5 4.1291.2000|
6 213.0000|
"

A1:A6 is my SKU's model number B1:B6 is my inventory C1:C6 should contain formulas that result in a summary of the models D1:D6 should contain formulas that result in a sum of the inventory count for each model

View 1 Replies View Related

Assign Column With ID

Oct 23, 2008

i have column with 40.000 entries. I have added to the column entry my ID
=B1&"?aid1425". How can i get rid off colum A without effecting column B with the ID?

View 3 Replies View Related

Assign Formula To A Name?

Dec 22, 2012

Is it possible to assign a formula to a name that is defined and use the defined name, that will be easier to use.

say =VLOOKUP($A:$A,Sheet1!$A:$B,2,FALSE)

I would like to use the above function and name it. Is there a way out?

View 3 Replies View Related

Assign Value Given Another Value In Range

Jan 21, 2013

I am doing an assignment about credit rating and I am trying to make a spread sheet based on Moody's credit rating method.

I have more or less finished my model, but I have one final problem; in the end I will come up with a numeric score, which can be translated into the final rating (Aaa,Aa1 etc.) based on some ranges. I just can not figure out how to formulate the formula, especially because I have no experience working with ranges.

I have tried with some IF formula's, but they seem to be way too long and complex, for what I imagine should be a relatively simple task.

In the attached sheet I have a final value of 6.9, which should give an A3 rating given that it is within the 6.5 - 7.5 range.

Test sheet.xlsx‎

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved