Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default Little help with "Number stored as Text"

Hi, everyone

I have this Macro doing a lookup from lookupfile then return "not
found" entries into the next sheet. The Macro works beautifully
however because my lookup values in sheet1 are phone numbers stored as
text. (i.e. 0290099009) with little green triangle symbol appearing on
left top of the cell when it actually does look up and transfer to
sheet2 it just copies it as a number (i.e. 290099009).

1. How do I make it copy to next sheet2 with exact same format as in
sheet1?
2. How do I make those "Not found" results from sheet1 deleted after
copying it to sheet2?

Thank you for your help in advance!

Sub Lookup()

Lookfname = "C:\MyDocs\Report.xls"
Set lookbk = Workbooks.Open(Filename:=Lookfname)
Set SearchRange = lookbk.Sheets("BID").Columns("G")

With Workbooks("Report.xls").Sheets("Sheet1")
Sh1RowCount = 3
Sh2RowCount = 3
Do While .Range("A" & Sh1RowCount) < ""
SearchValue = .Range("A" & Sh1RowCount)
Set c = SearchRange.Find(what:=SearchValue, LookIn:=xlValues,
lookat:=xlWhole)
If c Is Nothing Then
With Workbooks("Report.xls").Sheets("Sheet2")
.Range("A" & Sh2RowCount) = SearchValue
Sh2RowCount = Sh2RowCount + 1
End With
Else
.Range("B" & Sh1RowCount) = c.Offset(0, 6)
End If
Sh1RowCount = Sh1RowCount + 1
Loop
End With
lookbk.Close savechanges:=False

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Little help with "Number stored as Text"

To make numbers appear as text you would need to prefix with an apostrophe
('). So:

..Range("A" & Sh2RowCount) = "'" & SearchValue

"James8309" wrote:

Hi, everyone

I have this Macro doing a lookup from lookupfile then return "not
found" entries into the next sheet. The Macro works beautifully
however because my lookup values in sheet1 are phone numbers stored as
text. (i.e. 0290099009) with little green triangle symbol appearing on
left top of the cell when it actually does look up and transfer to
sheet2 it just copies it as a number (i.e. 290099009).

1. How do I make it copy to next sheet2 with exact same format as in
sheet1?
2. How do I make those "Not found" results from sheet1 deleted after
copying it to sheet2?

Thank you for your help in advance!

Sub Lookup()

Lookfname = "C:\MyDocs\Report.xls"
Set lookbk = Workbooks.Open(Filename:=Lookfname)
Set SearchRange = lookbk.Sheets("BID").Columns("G")

With Workbooks("Report.xls").Sheets("Sheet1")
Sh1RowCount = 3
Sh2RowCount = 3
Do While .Range("A" & Sh1RowCount) < ""
SearchValue = .Range("A" & Sh1RowCount)
Set c = SearchRange.Find(what:=SearchValue, LookIn:=xlValues,
lookat:=xlWhole)
If c Is Nothing Then
With Workbooks("Report.xls").Sheets("Sheet2")
.Range("A" & Sh2RowCount) = SearchValue
Sh2RowCount = Sh2RowCount + 1
End With
Else
.Range("B" & Sh1RowCount) = c.Offset(0, 6)
End If
Sh1RowCount = Sh1RowCount + 1
Loop
End With
lookbk.Close savechanges:=False

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I ignore the "Number stored as text" error message permane. reston33 Excel Discussion (Misc queries) 2 March 28th 07 02:59 AM
macro for converting number stored as "text" (or preceeded with ') to "number" formatting markx Excel Programming 1 June 30th 06 12:14 PM
macro for converting number stored as "text" (or preceeded with ') to "number" formatting markx Excel Programming 1 June 23rd 06 03:15 PM
Column listed as "Number Stored as Text" - Exported from Access Anthony C Excel Programming 1 September 30th 04 05:29 PM
unable to get original cell value from a "number stored as text" cedralpass Excel Programming 2 April 16th 04 10:51 PM


All times are GMT +1. The time now is 02:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"