Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
correct syntax for nesting "if", "and", and "vlookup"....if possib | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Syntax to "OR" 3 "ISERROR" conditions | Excel Worksheet Functions | |||
what is syntax for if(between range of dates,"Q1","Q2")? | Excel Worksheet Functions | |||
Better help in VBA for "NumberFormat Property" | Excel Programming |