LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Format of Variable

I avoid using variants like the plague. They are handy when necessary but
trouble the rest of the time (not to mention very ineffient).
--
HTH...

Jim Thomlinson


"Andibevan" wrote:

Hi Jim,

Thanks for your comments, it provided me with enough info to get my solution
to work - I had incorrectly declared a variable- Here's my working code:-

Sub Search_RefNo()
Dim xAssNum_Val As String
Dim xAssName As String

Application.ScreenUpdating = False
Application.Run "Sort_RefNo"

xAssNum_Val = Range("Enter_RefNo")
xAssName = Format(xAssNum_Val, "0000")

Selection.AutoFilter Field:=1, Criteria1:=xAssName, Operator:=xlAnd
Application.Goto Reference:="Enter_RefNo"
Selection.ClearContents
Application.ScreenUpdating = True
End Sub


Thanks

Andi

"Jim Thomlinson" wrote in message
...
So there are no misunderstandings. The item in the spreadsheet is 0001 as
text. You want to pick up that value and use it in code as the criteria for
an autofilter, but somehow you are getting an implicit conversion of the
item
to an integer? Is your variable declared as a string? If not make sure to
change it. To convert an interger to a string in VBA there is a CStr()
function and a format(number, format) function. Without seeing your code it
is a little difficult to comment on the best solution, but that should be a
start.
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Tom has given you the VBA method. Here is how to do it without VBA. Select
the cells in the range. Right Click. Format Cells. Custom - 0000
--
HTH...

Jim Thomlinson


"Andibevan" wrote:

Hi All,

I have a cell with a named range Enter_RefNo

I want to format this variable in the format as follow

1 -- 0001
10 -- 0010
11 -- 0011

And so on

Any ideas?

Regards

Andi






 
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
Convert variable #'s in a gen. format to a # that can be used w/ma Steve Excel Worksheet Functions 29 February 9th 10 01:19 AM
R1C1 format using a variable? jim37055 Excel Discussion (Misc queries) 3 October 4th 05 05:47 PM
Format columns using a variable name [email protected] Excel Programming 2 April 13th 05 02:43 PM
format variable to 3 decimal Wandering Mage Excel Programming 1 July 19th 04 04:53 PM
Variable Reference in R1C1 format Ndel40[_2_] Excel Programming 1 February 20th 04 10:21 PM


All times are GMT +1. The time now is 03:08 PM.

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

About Us

"It's about Microsoft Excel"