how can i paste result from excel formula to value or even store the result into a string

below codes does not seem to works...

For x = 2 To rowcount
    worksheet2.Range("B" & x).Value = worksheet2.Range("D" & x).Text
    worksheet2.Range("C" & x).Value = worksheet2.Range("E" & x).Text

worksheet2.Range("C" & x).Value = worksheet2.Range("E" & x).Text

please help... XD

4 Years
Discussion Span
Last Post by fourty

Hi, elouch, welcome at DaniWeb!
I use the following:
To put a string into a cell:
worksheet.Cells[row, col] = aString
To get a string from a cell:
aString = worksheet.Cells[row, col].Value2.ToString()
Hope it helps.
The Cells object is a Range object, that I find much more easier to work with in this case.

Edited by ddanbe: Typo


or you could simly use the range if you are familiar with it
dim mystr as string
mystr = worksheet2.Range("D" & x).value

same to the others
And just incase if you get the not set exception then set the ranges before you have to use them

I hope this helps too.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.