I have to use value of a cell in sheet1 to sheet2 using VBA. Please letme know how it could be possible using VBA.
Any cell in any worksheet can be referred to by being explicit thus:Thisworkbook.Sheets("Sheet2").Range("C3")=ThisWorkbook.Sheets("Sheet1").range("V45")(those last two lines should be on one line)orThisWorkbook.Sheets("Sheet1").range("V45").copyThisworkbook.Sheets("Sheet2").Range("C3")(those last two lines should also be on one line)
But if I want to store thisvalue in a variable then how could I do this.Please let em know.
to pass the info into avarialble and then paste the variable, you would use:Dim strString as StringstrString = ThisWorkbook.Sheets("Sheet1").range("V45")Thisworkbook.Sheets("Sheet2").Range("C3") = strString
You just need to put the variable name in front of the = sign instead of thedestination cell. ievariablename = ThisWorkbook.Sheets("Sheet1").range("V45")
I notice if you just add ".Value" after each statement it also work.Thisworkbook.Sheets("Sheet2").Range("C3").Value =ThisWorkbook.Sheets("Sheet1").Range("V45").ValueWould there be something drastic wrong with this?
No, that's fine. What's going on is that .Value is the default propertyof the .Range object, so it is assumed to be the relevant property ifyou omit it.