+ Reply to Thread
Results 1 to 7 of 7

Recording contents of cells into multiple columns

Hybrid View

  1. #1
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Recording contents of cells into multiple columns

    deleted: see my next post
    Last edited by tony h; 04-19-2010 at 06:59 AM.


    click on the * Add Reputation if this was useful or entertaining.

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Recording contents of cells into multiple columns

    Ok, I have had a bit of a look and I think the code below should do the job.
    What you do need to do is make sure that the connection is set with the "enable background refresh" to "off" ie un-ticked.
    : on the data tab ... go to connections ... existing connections and pick properties

    Sub GetData2()
        Dim rng As Range
        Dim i As Long
        Dim dte As Date
        Dim dteNext As Date
        Dim iMax As Long
        Dim wkb As Workbook
        
        Set wkb = ThisWorkbook
        dte = Now
        Set rng = ActiveSheet.Range("M1")
        iMax = 3 'change this to number of time to loop
        For i = 1 To iMax
            wkb.RefreshAll
            
            
            rng = Now
            
            ''
            ''change this block to the actually addresses you need
            ''
            rng.Offset(, 1) = ActiveSheet.Range("B3")   '1st piece of data
            rng.Offset(, 2) = ActiveSheet.Range("B15")  '2nd piece of data
            rng.Offset(, 3) = ActiveSheet.Range("B16")  '3rd piece of data
            
            Set rng = rng.Offset(1)
            dteNext = dte + TimeSerial(Hour:=0, Minute:=1 * i, Second:=0) 'change this value to number of minutes
            'Application.Wait dteNext
            If i <> iMax Then Do: DoEvents: rng = Now: Loop Until Now >= dteNext
        Next
        MsgBox "done"
    End Sub

  3. #3
    Registered User
    Join Date
    04-16-2010
    Location
    london,england
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Recording contents of cells into multiple columns

    Thanks tony h for your huge effort to help. I am now off work until friday due to my shift pattern and so wont be able to try out your new code until then. As you can tell I am no programmer but will let you know how it goes over the weekend.

  4. #4
    Registered User
    Join Date
    04-16-2010
    Location
    london,england
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Recording contents of cells into multiple columns

    I would like to thank tony h for supplying this answer to my problem. I am now able to record all my data from the building management system IP addresses onto one excel sheet. I just have one last request if anyone can help, I would like to be able to type in comments on the same sheet when the returned data is out of limits, but when I do this the macro stops working and I have to restart it. Does anyone know a way of getting around this problem. Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1