Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default NumberFormat = "@" syntax

I understand that to convert a numeric Cell import source
to a destination cell String, I need to transit the cell value to a
String Variable
then, load the String Variable to the destination cell.
My Import Source Column A, has a mix of Data Type 1 and 2.
I want the Destination Cells to be in Data Type 2 only (String),
But I am still struggling with the following code :
..
Sub Convert()
Dim LastRow As Integer: Dim i As Integer
Dim wbA As Workbook: Dim wbB As Workbook
Dim myPath As String: Dim Temp As String
myPath = "C:\"
Set wbA = Workbooks.Open(myPath & "A.xls")
ActiveWorkbook.Sheets(1).Select
LastRow = Range("A65335").End(xlUp).Row
Set wbB = Workbooks.Open(myPath & "B.xls")
i = 2
Do While i <= LastRow
wbA.Cells(i, 1).NumberFormat = "@"
' Error on above line : Object does not support this property or
method
Temp = wbA.Cells(i, 1)
wbB.Cells(i, 1).Value = Temp
i = i + 1
Loop
End Sub
..
Help appreciated,
J.P.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default NumberFormat = "@" syntax

The Cells property belongs to a Worksheet, not a Workbook. Your code

Dim wbA As Workbook: Dim wbB As Workbook


declares both wbA and wbB as Workbooks, not Worksheets, and the Cells
method doesn't belong to Workbooks. You need to reference a worksheet
within wbA or wbB. E.g.,

wbA.Worksheets("Sheet Name").Cells.NumberFormat = "@"

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Fri, 24 Oct 2008 08:09:38 -0700 (PDT), u473 wrote:

I understand that to convert a numeric Cell import source
to a destination cell String, I need to transit the cell value to a
String Variable
then, load the String Variable to the destination cell.
My Import Source Column A, has a mix of Data Type 1 and 2.
I want the Destination Cells to be in Data Type 2 only (String),
But I am still struggling with the following code :
.
Sub Convert()
Dim LastRow As Integer: Dim i As Integer
Dim wbA As Workbook: Dim wbB As Workbook
Dim myPath As String: Dim Temp As String
myPath = "C:\"
Set wbA = Workbooks.Open(myPath & "A.xls")
ActiveWorkbook.Sheets(1).Select
LastRow = Range("A65335").End(xlUp).Row
Set wbB = Workbooks.Open(myPath & "B.xls")
i = 2
Do While i <= LastRow
wbA.Cells(i, 1).NumberFormat = "@"
' Error on above line : Object does not support this property or
method
Temp = wbA.Cells(i, 1)
wbB.Cells(i, 1).Value = Temp
i = i + 1
Loop
End Sub
.
Help appreciated,
J.P.

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
correct syntax for nesting "if", "and", and "vlookup"....if possib Christine Excel Worksheet Functions 4 January 2nd 09 10:43 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Syntax to "OR" 3 "ISERROR" conditions Mike K Excel Worksheet Functions 6 July 22nd 06 04:18 PM
what is syntax for if(between range of dates,"Q1","Q2")? TLB Excel Worksheet Functions 3 December 6th 05 05:19 PM
Better help in VBA for "NumberFormat Property" Bengt Nilsson, Staffanstorp, Sweden Excel Programming 2 October 10th 04 06:20 AM


All times are GMT +1. The time now is 12:50 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"