-
Excel thru VB
hi all...
i'm making a button in an excel spreadsheet through VB. the functionality of that button is to copy the cells selected and return the value. i've come to know of the range of the cells selected. now here comes the problem.....is there any way by which i can retrive the data in that range ???
this is urgent...plz help
thnx
-
ok i have the data by this method...
Code:
For i = 1 To rng.Rows.Count
For j = 1 To rng.Columns.Count
strMess = strMess & rng.Cells(i, j) & ":"
Next
Next
now my problem is that if i have used any formulas in the selected range..that wont come..only the value in the cell comes.....c'mon ppl please help
-
Look into Paste Special in Excel.
Also, whenever having trouble with VB/VBA coding in Excel, simply start Recording a new macro in Excel, do what you want to do manually [with mouse or menu], then edit the macro to see the code.
-
rng.cells(i,j).value - returns the value in the cell
rng.cells(i,j).formula - returns the formula
-
thnx for ur help..that problem is solved
now i'm bothering u with another one....how do u copy other objects..like OLE, chart, image, wordart, etc in the same way as the data/formula in the cells ???
urgent...thnx again
-
I think you can get the count of the shapes with this:
ActiveSheet.Shapes.Count
so maybe...
For x = 1 to ActiveSheet.Shapes.Count
ActiveSheet.Shapes(x).Select
Selection.Copy
'paste it somewhere...
Next
you'll have to play a bit with it..
Remember...record macros!
look at the code (ALT F11)