By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,743 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,743 IT Pros & Developers. It's quick & easy.

format an excel cell

juve11
P: 20
hello,
i made alot of changes to an excel sheet from visual basic like bordering,setting landscape,margins... but there is a thing a didnt managed to change : the cell format.

i have two columns and i need that all the cells from those columns to be type "text"

do you have any ideas?

thank you
Nov 6 '07 #1
Share this Question
Share on Google+
4 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

This makes Column B and Column C as Text Columns..

Expand|Select|Wrap|Line Numbers
  1. Range("B:B").NumberFormat = "@"
  2. Range("C:C").NumberFormat = "@"
  3.  
Say you want only first 20 Cells of Columnd as Text, then:

Expand|Select|Wrap|Line Numbers
  1. Range("D1:D20").NumberFormat = "@"
  2.  
Regards
Veena
Nov 6 '07 #2

juve11
P: 20
hi,thank you for posting!
i try in my project you're idea but doesnt works like i need : i have a database in access wich i am taking to excel via visual basic. the database contains two columns with telephone numbers : standalone and mobile. both start with "0".so, when i put the database in excel it does not trasfer the leading "0" , just the rest of the number.

i sauth that if i format the cell to "text" everything is ok,that's why i asked how do you change the type of a cell in excel from visual basic.

thank you.
Nov 6 '07 #3

QVeen72
Expert 100+
P: 1,445
Hi,

Pass the above Code (My Previous Post), before populating the data to Excel, or PreFix the database Text Value with Single Quote say:

Expand|Select|Wrap|Line Numbers
  1. Cells(10, 2 ) = "'" & RST("MyFieldName")
  2.  
Preceeding Quote ensures, it as a Text Field..

Regards
Veena
Nov 6 '07 #4

juve11
P: 20
indeed, you are right, thank you very much for youre time.

my best regards.
Nov 6 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.