Please help to Automate my Spreadsheet Using If conditions in Macros

kinirobin

New Member
Joined
Jan 10, 2012
Messages
18
Hi All,
I have a sheet with columns Amount, City and Name. I have a set of names for each location ex: North - Mr.X, Mr.Y, South - Mr. A, Mr. B, East - Mr. D, Mr.F. And a few cities in each of the locations Like North - Boston, Detroit Etc.

Can Anyone please help me to provide a if condition formula or a Macro which looks at a range of amount(<=200) , City and then give the name of the person as per the cities in a location. Ex.

Amount City Name

$200 Boston Mr. X

Many Thanks,
Kinirobin
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
This will filter the rows where the value in column A is <=200 and will put those items with their corresponding name and address in columns E:G beginning at row 2. the code should be copied to the standard code module 1. See bottom of post for accesss instructions.
Code:
Sub getNameaddr()
Dim sh As Worksheet, lr As Long
Set sh = Sheets(1) 'Edit sheet name
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
sh.Range("A1:C" & lr).AutoFilter 1, "<=200"
sh.Range("A2:C" & lr).SpecialCells(xlCellTypeVisible).Copy sh.Range("E2")
sh.UsedRange.AutoFilter
End Sub
 
Upvote 0
Thanks for the quick response JLGWhiz, My question was little different, may be I have not put across my point correctly the first time.

Each Region has a list of cities in it for Example - North = Boston, Detroit. South = Dallas, Florida. West = California, Memphis

So imagine if 450 is entered in Column A and Boston is entered in Column B then the Column C should auto calculate and show - Mr. A

Here is the example:


Range E.g dataNorthSouthWest
500 < = 450Mr. AMr. AMr. A
501-4999 550Mr. A, Mr. B, Mr. CMr. A, Mr. BMr. B, Mr. C
5000-24999 5,500Mr.X, Mr.YMr. D, Mr. OMR. L
25000-49999 25,500Mr. M, Mr, GMr. B, Mr. AMr. W, Mr. I
50000 > 55,000Mr. E, Mr. FMr. J, Mr. SMr. Z, Mr. N

<tbody>
</tbody>
Hope This helps.

Many thanks,

Kinirobin
 
Upvote 0

Forum statistics

Threads
1,215,544
Messages
6,125,438
Members
449,225
Latest member
mparcado

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top