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
Next


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

please help... XD

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.

Ooops the square brackets [] have to be round brackets () of course!

thanks a lot danbe!! your a life saver...

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.