+ Reply to Thread
Results 1 to 5 of 5

Copy all cells in range if not isempty

  1. #1
    Registered User
    Join Date
    08-31-2012
    Location
    HK
    MS-Off Ver
    Excel 2003
    Posts
    14

    Copy all cells in range if not isempty

    hi guys,

    have a stock price/volume spreadsheet that updates in realtime.

    goal is to run a macro that loops every second between 09:00:00 and 09:30:00 and copies all the cells from bVolume/aVolume (columns I/K) to corresponding columns O/Q, but only if values are nonzero

    therefore, if the bVolume/aVolume is zero for any given price, it will not overwrite the previous copied volume

    have attempted to write macro in attached s/s but can't quite perfect it

    please help!

    Dim timeToRun
    Sub copyPrices()
    timeToRun = Now + TimeValue("00:00:01")
    Application.OnTime timeToRun, "rangePaste"
    End Sub

    Sub rangePaste()
    Dim ocell, qcell As Range
    For Each ocell In Range("I4:I65")
    If IsNumeric(ocell) Then
    ocell.Copy (Range("O4:O65"))

    Next ocell

    For Each qcell In Range("K4:K65")
    If IsNumeric(qcell) Then
    qcell.Copy (Range("Q4:Q65"))
    End If
    Next qcell

    If Now < "9:29:58" Then
    Call copyPrices
    Else: Exit Sub
    End If
    End Sub


    matchtest2.xlsm

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy all cells in range if not isempty

    I'm not 100% certain what you want but I think it is this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-31-2012
    Location
    HK
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Copy all cells in range if not isempty

    i probably wasn't entirely clear what i wanted but have amended your code to achieve desired result

    thanks for the help!

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-31-2012
    Location
    HK
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Copy all cells in range if not isempty

    still having a minor issue here - this is the amended code however the cells with data (ie not empty) that should be copying to columns O and Q are not appearing - ie O/Q seem to be blanking themselves with each iteration
    Please Login or Register  to view this content.
    could somebody pls point me in the right direction? cheers

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy all cells in range if not isempty

    Works fine on your sample for me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 05-31-2012, 05:37 AM
  2. Isempty with cells
    By katto01 in forum Excel General
    Replies: 2
    Last Post: 02-08-2012, 03:03 AM
  3. Can you do IsEmpty(Range)?
    By Sharkbait in forum Excel General
    Replies: 6
    Last Post: 08-08-2006, 05:45 PM
  4. [SOLVED] Can you do IsEmpty(Range)?
    By Sharkbait in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2006, 12:05 PM
  5. IsEmpty() Returns False in empty cells
    By John Hutchins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2005, 10:07 PM

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