Results 1 to 6 of 6

Thread: Excel thru VB

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47

    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

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    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

  3. #3
    Fanatic Member doofusboy's Avatar
    Join Date
    Apr 2003
    Posts
    526
    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.
    Do canibals not eat clowns because they taste funny?

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    rng.cells(i,j).value - returns the value in the cell
    rng.cells(i,j).formula - returns the formula
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    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

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    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)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width