VBA find from 2nd excel sheet back to 1st sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This doesn't work:
I have a city name on Stationsheet. I select the contents of the cell.
I jump to AreaCode sheet and Ctrl+F and then paste the value in the search.
Then I HOME to the leftmost cell and select it.
Then I jump back to StationSheet.
I right arrow to the third cell and I paste the areacode.

The generated code has fixed cells and ranges.
I want to have it refer to a selection on the clipboard and I want to command right arrows.
Can you help?

Sub GetAC()
'
' GetAC Macro
' Macro recorded 3/22/2004 by Clifford W. Lazar
'
' Keyboard Shortcut: Ctrl+y
'
Selection.Copy

Sheets("AreaCodes").Select
'.Select
Cells.Find(What:=selection.value, After:=Range("A1"), LookIn:=xlFormulas,
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Range(ActiveCell).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("TVStations").Select
Range("D5").Select
ActiveSheet.Paste
Range("A6").Select
'ActiveCell
End Sub
 
Cliff,

If I'm understanding you correctly, I think you should use a Vlookup formula
in your cell where you want your area codes. If you have a table of cities
and area codes, this function will allow you to specify the city name and
will return the area code. Look at Vlookup in Excel Help and sorry if I'm
not understanding.

hth,

Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top