ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set a column to "text" (https://www.excelbanter.com/excel-programming/434744-set-column-text.html)

Jims

Set a column to "text"
 
I'm using Office 2007, using the Excel object model from Access VBA. I want
to select a column (say, column G), then turn it all to text. It may contain
mostly numbers, but I want Excel (and ultimately Access) to see the entire
column as text. There is a way to do this manually, but I need to do it
through VBA. Anybody got a quick code snippet they could share? I'd
appreciate it....

--
Jim

Rick Rothstein

Set a column to "text"
 
I don't use Access, so I'm not sure about requirements, if any, for running
the Excel object model from within it; however, the VBA statement that
formats Column "G" as Text is this...

Columns("G").NumberFormat = "@"

--
Rick (MVP - Excel)


"JimS" wrote in message
...
I'm using Office 2007, using the Excel object model from Access VBA. I
want
to select a column (say, column G), then turn it all to text. It may
contain
mostly numbers, but I want Excel (and ultimately Access) to see the entire
column as text. There is a way to do this manually, but I need to do it
through VBA. Anybody got a quick code snippet they could share? I'd
appreciate it....

--
Jim



Tom Lavedas[_2_]

Set a column to "text"
 
On Oct 8, 3:50*pm, JimS wrote:
I'm using Office 2007, using the Excel object model from Access VBA. I want
to select a column (say, column G), then turn it all to text. It may contain
mostly numbers, but I want Excel (and ultimately Access) to see the entire
column as text. There is a way to do this manually, but I need to do it
through VBA. Anybody got a quick code snippet they could share? I'd
appreciate it....

--
Jim


Have you tried this? ...

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 10/08/2009 by Tom Lavedas
'

'
Columns("G:G").Select
Selection.NumberFormat = "@"
End Sub
_____________________
Tom Lavedas


All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com