Read Character from Excel file

E

ebenozen

I'm having a hard time reading string data from 1 Excel file into
another. The code works fine for numeric input, but reads bogus data
when reading strings.

Set wb = Workbooks.Open(path & fname, True, True)
With ThisWorkbook.Worksheets("chart_data")
.Cells(rw - 5, cl) = wb.Worksheets("Diorite").Cells(9,
5) 'Read character string text here doesn't work
.Cells(rw + 1, cl) = (wb.Worksheets("Diorite").Cells
(2, 2) + wb.Worksheets("Diorite").Cells(2, 4)) / 2 'Read numeric data
and calc works fine here
End With

I'm a novice user. Appreciate the help.
 
M

macropod

try:

With ThisWorkbookWorksheets("chart_data")
.Cells(rw - 5, cl).Value = wb.Worksheets("Diorite").Cells(9, 5).Value
.Cells(rw + 1, cl).Value = (wb.Worksheets("Diorite").Cells(2, 2).Value + _
wbWorksheets("Diorite").Cells(2, 4).Value) / 2
End With
 
E

ebenozen

try:

With ThisWorkbookWorksheets("chart_data")
  .Cells(rw - 5, cl).Value = wb.Worksheets("Diorite").Cells(9, 5).Value
  .Cells(rw + 1, cl).Value = (wb.Worksheets("Diorite").Cells(2, 2).Value + _
    wbWorksheets("Diorite").Cells(2, 4).Value) / 2
End With

--
Cheers
macropod
[MVP - Microsoft Word]

I'm having a hard time reading string data from 1 Excel file into
another.  The code works fine for numeric input, but reads bogus data
when reading strings.
Set wb = Workbooks.Open(path & fname, True, True)
With ThisWorkbook.Worksheets("chart_data")
               .Cells(rw - 5, cl) = wb.Worksheets("Diorite").Cells(9,
5) 'Read character string text here doesn't work
               .Cells(rw + 1, cl) = (wb.Worksheets("Diorite").Cells
(2, 2) + wb.Worksheets("Diorite").Cells(2, 4)) / 2 'Read numeric data
and calc works fine here
End With
I'm a novice user.  Appreciate the help.

Got it working. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top