Inserting State Names Based On Telephone Numbers

Oct 22, 2007

I have a large data set (excel file), of "Names", "Phone Numbers", and i need to sort this based on the States that correspond with the Phone numbers. The states currently do not exist in the spreadsheet, so my current problem is trying to insert those states into the spreadsheet.

There are over 100 area codes in the data set, so i'll likely have to write a large "If" statement in VB to run through them all, but that shouldnt be a problem.

NAME, PHONE, STATE
Bleh, 555-555-5555, =ChkState(B2)

I've been playing around with the VB Stuff in Excel and this is what i've come up with for trying to insert the State field

Function ChkState(pVal As String) As Long

Dim AreaCode As String
Dim StateAbrv As String

AreaCode = Left(pVal, 3)

If AreaCode = "201" Then
StateAbrv = "Test201"
ElseIf AreaCode = "203" Then
StateAbrv = "Test203"
ElseIf AreaCode = "555" Then
StateAbrv = "Test555"
Else
StateAbrv = "0"
End If
MsgBox StateAbrv
End Function

I'm fairly new to this VB stuff, my main problem stems from trying to insert the "StateAbrv" back into the Cell for the spreadsheet.

View 9 Replies


ADVERTISEMENT

Formating Telephone Numbers

Feb 9, 2005

Is it possible to format cells so that inputed tel. numbers are all have the same format and not just appear the same, regardless of how they were typed in?
i need it so the column can be sorded by phone #.

View 9 Replies View Related

Removing Telephone Numbers From A Cell?

Jun 1, 2013

I have a limited amount of VBA knowledge. My limited knowledge is based on solving my problems by looking at the answers already on this site and trying to adapt it to my needs. Here goes:

I import a list of address and telephone numbers (100+) into excel. example - Cell A1 contains "10 downing street, whitehall, london, SW1A 2AA 01234 567890", sometimes there is another space after the number, sometimes there is no telephone number. I want to remove the telephone number at the end if it is there. Have searched the forums have have come up with the follow solution:

1. import list to column A
2. copy and paste Trim to column B
3. copy values in column B and paste to column A
4. delete column B
5. remove the end numbers
6. copy and paste Trim to column B
7. copy values in column B and paste to column A
8. delete column B
9. remove the end numbers

It looks like this in code:

Sub testa()

'select (=TRIM(A1)) formula and paste to sheet
Sheets("Formulas").Select
Columns("B:B").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Columns("B:B").Select
ActiveSheet.Paste

[Code]...

'copy values of column B to Column A and delete column B

Columns("B:B").Select
Selection.Copy
Columns("A:A").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("B:B").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A1").Select

[Code]...

'copy values of column B to Column A and delete column B

Columns("B:B").Select
Selection.Copy
Columns("A:A").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("B:B").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A1").Select
End Sub

I know this is a long winded way around (still chuffed I worked it out by myself though!). If I merge all the macros into one marco it continually loops and deletes everything in the cells and I have to press escape to stop it.

My questions are:

1. Why, when I merge all the macros doesnt it work the same as individual macros? (I would like to know for future reference).
2. Its there a better way to remove the telephone numbers?

View 3 Replies View Related

Insert Spaces In Telephone Numbers

Aug 24, 2007

I have a column that contains all telephone numbers without any spaces - 01234567890

I need to have at least one space inserted anywhere in the number i.e. 0 1234567890 or 01234 567890.

View 8 Replies View Related

Cleanup Telephone Numbers Have Some Text Data?

Aug 16, 2014

I have some cells which contain telephone number and some text data. They look like this.

(713) 555-4600 (Work)
(713) 555-4620 (Home)
(832) 555-4610 (John's Phone)

I need to strip out the text data and just display the phone number as follows

(713) 555-4600
(713) 555-4620
(832) 555-4610

View 4 Replies View Related

Sum Numbers Based On Corresponding Names

Dec 15, 2008

Using two columns of data:
Column A with a list of first names sorted by first name, Column B with a different integer value for every cell in Column A. How do I write a formula that sums the values contained in Column B for each unique first name in Column A? The formula needs to identify where first name changes in Column A as there are different numbers of entries in Column A for each first name. (Note: I do not wish to use sub-totals, as I want to copy/paste values back into the results column and use sort to generate a new lookup table)

Have attached an example of the two columns I would like to test. Ideally I would like to see the results in a third adjacent column with the sum displayed only where a new first name appears in first column (the cells would be blank in the third column when the first name is the same as the row above).

View 8 Replies View Related

Creating Sum Of Numbers Based On List Of Names

Jan 27, 2013

I am a small business owner with little experience in Excel and I have been trying to set up a worksheet that will organize my products and finances. I organize sets of various products and sell them in bulk to customers. I was trying to recreate this in Excel so I can figure out the total price for each of these sets and easily edit them.

What I've been trying to do is to take a list of the items and assign a price to each of them. This is on a sheet titled "Prices." Here's an example:

prices.jpg

On a separate sheet titled "Sets," I created lists of items included in each particular set. To easily add or change the products I used drop down menus.

sets.jpg

I would like for the sum of the price of all the items listed under each set to add up automatically in the "Total" row. For example, in cell B7 it should display the number 10. Here is a list of the following formulas I've tried:

[Code] ........

View 2 Replies View Related

Returning State Cities By Inputting Given State Abbreviation

Jun 3, 2012

I'm trying to create an array formula that returns all the cities in a given state by imputing the state's abb in cell K2. The returned cities go into column J. California has the most cities(430) and the cities are 5000 rows deep.

View 7 Replies View Related

How To Populate Table With Names Based On Cell Numbers

Mar 13, 2014

I have a column (A) with names, Column (B) with platoon numbers. On another sheet I have a table for each platoon and I want it to be populated with the names of each platoon indevidually. The names are alphabetically and the platoon numbers are mixed.

Column A Column B
Name Platoon
J Goodman 1
L Barns 7
H Law 1
B Aims 10

and so on....

I want all the names from platoon 1 to appear in the table for platoon 1. I have about 3000 members and 40 platoons.

View 3 Replies View Related

Inserting Into Range Names

Jun 28, 2012

Suppose that i have a table that displays different metrics for each month of the year. I'm dealing with waste management at a thrift store so I'm looking at the weight of donations salvaged, weight of donations sent to landfill and weight sold and so forth. It would look something like this..

weight sent to landfill
weight sold

january
500
450

february
350
390

march
400
789

In my dashboard I'd like to be able to sum the total weight salvaged for certain months like Jan-Feb or Jan-March.

I've named the ranges such as "weightsalvaged.Jan_Feb". So for the sum of the weight salvaged, I have the formula =sum(weightsalvaged.Jan_Feb)

I would like to have another cell where I write "Mar" and the name of the range in the formula automatically changes from

=sum(weightsalvaged.Jan_Feb) TO =sum(weightsalvaged.Jan_Mar)

View 3 Replies View Related

Set Cell Color Based On CheckBox State

Jan 18, 2008

I want to write code for a Checkbox that when checked it fills a cell with a color, but if it is subsequently unchecked, the cell color disappears.

View 9 Replies View Related

Automatically Calculate Based On CheckBox State

Jan 23, 2008

I have a Worksheet_Change event like the one below. When Checkbox1 is ticked the it subtracts and when it's not, it adds:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim intValue As Integer
If Not Intersect(Target, Range("W12:X24")) Is Nothing Then
intValue = CInt(Target.Value)
If CheckBox1.Value Then intValue = intValue * -1
Select Case Target
' Apples
Case Is = Range("W12")
Logbook.Show
Range("I10").Value = CInt(Range("I10").Value) + intValue
Case Is = Range("X12")........................

View 7 Replies View Related

Call Macro Based On CheckBox State

Mar 12, 2008

I have a checkbox and a command button on my sheet. I want that, depending if the checkbox is marked or not, I can call two different macros. I don't know if this is possible at all or maybe can be done easier otheriwise, but this would more or less be my idea of what should happen:

Private Sub CommandButton1_Click ()
' If CheckBox1 = marked
Call MacroA

'Else (CheckBox1 = unmarked)
Call MacroB
' End If
End Sub

View 4 Replies View Related

Return State Value Based On Match Of Name And Number Between High And Low

Aug 27, 2013

I have a set of data (Data tab) that lists name, a high number, a low number, and the state that is associated with the name and range between the high and low number (see attachment). I am trying to figure out a formula that will return the state value based on a match of the name and the number between the high and low. I am trying to use Index/Match but i cant figure out the "between the high and low" portion.

tester.xlsx

View 2 Replies View Related

Tally Cell Automatically Based On CheckBox State

Jan 18, 2008

In my spreadsheet the user has the option to put in a numerical value into different cells, which will update (add to) another. So if we have an initail value of 20 in "I10" and the user puts in 20 in "W12", then I10 will display 30.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("W12:X24")) Is Nothing Then
Select Case Target
Case Is = Range("W12")
Logbook.Show
Range("I10").Value = CInt(Range("I10").Value) + CInt(Target.Value)
Case Is = Range("X12")
Logbook.Show
Range("J10").Value = CInt(Range("J10").Value) + CInt(Target.Value)
Case Is = Range("W13")
Logbook.Show.................

View 6 Replies View Related

VBA For Inserting Input String Alphabetically Into Column Of Names?

Oct 2, 2013

I have a list of names in the A column of the sheet. I wish to use the input string, a new name, of a vba box to insert into the column of existing names in alphabetical order by inserting an entire row, which I suspect will be the case anyway. Also 'Return' key doesn't seem to be inserting a CR on the page that I typed this request upon.

View 5 Replies View Related

Telephone Dialing Code

Jan 2, 2008

This has definitely been done before, but I am not sure if it has been done through Excel/VBA.

I have a 9 or 10 digit telephone number, preceded by a zero and what I want to do is get Excel to figure out the combinations of text characters that will allow me to have a text phone number.

For Example:
0-800-43573375 is the same as 0-800-HELPDESK

View 9 Replies View Related

Inserting Text Infront Of Numbers

May 18, 2009

Yesterday I got the solution to insert the text by using custom format. Exampe: 112233 to Ab-112233 by using "Ab-"General

But when I tried the same method to inserset the Ab on 11-1122

Like 11-1122 into Ab-11-1122 in same cell, it doesn't work.

View 6 Replies View Related

Inserting Sequential Numbers Into A Column

Oct 1, 2009

I have a column of an undefined number of rows where I need to add item numbers from 1 to however many items there are, starting from A9 downwards.

The last 3 used rows on the sheet contain signatures etc so it should not number the bottom 3 rows.

pretty sure its fairly simple code but i dont have anything similar from previous files that i can re-use to do this :p

just needs a simple

count how many rows are blank from A9 downwards (to say A200)
for num=1 to count do
Cell range(A(9+num) = num
end

i just dont know the code well enough to write it and make it work :p

View 3 Replies View Related

Automatically Inserting Numbers Into Text

Jul 25, 2008

How can I have a number inserted into text on an excel sheet. for example if I have the number 100 in cell A1 and I want it inserted into the following sentence in sell A2:

You are 100 years old. I want the number to be able to change automatically in this sentence when the number in A1 also changes.

View 9 Replies View Related

Inserting A Text(alphabate) In A List Of Numbers

May 16, 2009

suppsose i have 50 list of numbers in column A. I want to insert a text "AAB-" in whole list. How can I do that.

FROM:

1122
1123
1124
1125

To:

AAB-1122
AAB-1123
AAB-1124
AAB-1125

View 9 Replies View Related

Inserting Minus Sign In Front Of Numbers In A Range

Mar 19, 2009

i want to know how to prefix a minus sign (-) before numbers in cells in a large range.i m working on a large sheet containing the Numbers with Cr and Dr as suffixes just like 445Dr ... 3331Cr and so..on... in the worksheet

i want to know the method of deleting the suffixes and prefixing - sign infront of numbers having Cr as the suffix.

Numbers with Dr as suffix denote positive numbers
and numbers with Cr suffix denote negative numbers. i want to prefix the -minus sign in front of numbers having Cr in the end.

View 8 Replies View Related

Inserting Columns With Numbers Relative To Previous Data

Jan 19, 2012

the following issue:

I have a spreadsheet of questionnaire responses which range from 1-7

For example:

Respondent Q1

1 4
2 3
3 7
4 6

So each row is a new respondent and each column is their response from the scale.

What I need to do is code the responses into a different form. I need them to be represented as follows:

Respondent Answer1 Answer2 Answer3 Answer4 Answer 5 Answer 6 Answer 7

1 0 0 0 1 0 0 0
2 0 0 1 0 0 0 0

So that each number then represents the place on the scale from which it was chosen.

I tried recording a macro but I think this requires something a lot more complex.

View 3 Replies View Related

Totaling Numbers By Names

Sep 8, 2013

[URL]

The output of my magic spreadsheet, developed to run the local flower show, is a column of names - each of which have won a prize valued in points. I need to determine which person in the list of names has won the most points in total, in order to award a trophy.

Actually, I also need to know how many points each individual has got because - as we all know - points make prizes. And I need to write out one prize voucher for each individual, to the total value of what they won.

Now I have been sorting each column alphabetically, then manually totting up the points, and adding the three totals together. But surely, there must be a way to do this automatically? I don't really want to have to sort the columns at all... just have the answers appear like magic once the data is in the data entry part of the sheet.

Here's an example:

1ST PRIZE
NAME
VALUE
2ND PRIZE

[Code].....

View 9 Replies View Related

Seperate Names From Numbers

Apr 27, 2007

I have the following list of names, phone and radio numbers that somebody put together all in one cell. Formated as General with Word Wrap.is.

View 9 Replies View Related

Inserting Row Based On Condition

May 4, 2009

I want to insert a line wherever I encounter a number. I have a range of cells in column "A" with invoices listed and at the end of each customer I have the total. At the total line (the number) I want to insert a line. Right now I can't figure out how get the cell value to recognize a number from a non-number data type (bolded area)

View 5 Replies View Related

Inserting Row In Excel Using VBA Based On Y Value

Apr 18, 2013

i would to insert a row in excel using vba based on a y value

if insert.row = y(any value) then those many rows should insert

View 4 Replies View Related

Inserting Lines Based On IF

Aug 13, 2008

I have an amount of data split into various fields. I need to do something similar to the following:

In each row I have three fields separated by columns: name, sector and specialty. There is only one name and one sector for each record, but possibly several specialties (of which there are fifteen types in total, so they do not appear in a consistent column. specialty 'i' could appear in columns 3, 4, 5 through to 17. ie, sample entries below:

sheet 1
a1 name a2 sector a3 specialty i a4 specialty iv
b2 name b2 sector b3 specialty ii b3 specialty iv b4 specialty x
c3 name c4 sector c5 specialty i c6 specialty ii

The thing is, for every specialty in a row, I need new records created, so the above would become:

sheet 2
a1 name a2 sector a3 specialty i
a1 name a2 sector a3 a4 specialty iv
b2 name b2 sector b3 specialty ii
b2 name b2 sector b3 specialty iv
b2 name b2 sector b4 specialty x
c3 name c4 sector c5 specialty i
c3 name c4 sector c6 specialty ii

View 9 Replies View Related

Sorting Names By Other Column Of Numbers

Aug 3, 2014

I've question in sorting: I've 2 column in one datasheet. one contain value of numbers and the other contain names of employes. i want to sort the name of the emplyes by the values that is on the first column.

Anther question is how to make it dynamically so ill not sorting it every time that the values of the first column is changing.

View 1 Replies View Related

Sum Up Numbers Connected To Repeating Names?

Nov 3, 2008

I have an excel assignment that has about 4000 orders for wood. I am suposed to find the company that ordered the most wood and of what kind. I am really at a loss for how to do this and have combed over my book quite afew times trying to figure it out. However it has little if any excel info and nor does the ** that came with it outside of how to install data analysis tools. I figure I need to find a way to get excel to combine the numbers together for orders from the same company but after trying for afew hours I have gotten no where.

View 3 Replies View Related







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