Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #330

Re: Can't select a range of data/single cell

From GS <gs@somewhere.net>
Newsgroups comp.lang.basic.visual.misc
Subject Re: Can't select a range of data/single cell
Date 2011-07-11 18:44 -0400
Organization A noiseless patient Spider
Message-ID <ivfucb$d42$1@dont-email.me> (permalink)
References <b964278e-bbec-469a-8b70-b43082160b26@f35g2000vbr.googlegroups.com>

Show all headers | View raw


Firstly, this is a Classic VB group and so you need to post to an Excel 
group such as  "microsoft.public.excel.programming".

Otherwise, I assume you want to increment rows on Sheets("Hourly KWD 
Trends") for each line of data being copied to there. Also, you don't 
need to select anything in this procedure and so I've rewritten it as 
how I would do this task if it was one of my projects. I hope this is 
helpful...

''''''''''''''''''''''''''''''''''''''''''''''''''
' FillHourlyKWDdata Macro                        '
' Loops through data in main sheet               '
' Copies Average rows and date from each day     '
' Pastes the rows and date into Hourly KWD Trends'
''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FillHourlyKWDdata()
  Dim rngSource As Range, rngTarget As Range
  Dim i As Integer

  With Sheets("All Data")
    .Visible = True: Set rngSource = .Range("A10")
  End With
  With Sheets("Hourly KWD Trends")
    .Visible = True: Set rngTarget = .Range("A2")
  End With

  For i = 10 To 230 Step 5
    With rngSource
      If .Offset(0, 1).HasFormula Then
        rngTarget = .Offset(-4, 25)
        'select next column over
        With rngTarget.Offset(0, 1).Resize(, 25)
        .Value = rngSource.Offset(0, 1).Resize(, 25).Value
        End With 'rngTarget.Offset(0, 1).Resize(, 25)
        Set rngSource = rngSource.Offset(5, 0)
        Set rngTarget = rngTarget.Offset(1, 0)
      Else
        Set rngSource = rngSource.Offset(1, 0)
      End If 'rngSource.Offset(0, 1).HasFormula
    End With 'rngSource
  Next 'i
  Application.Goto Sheets("All Data").Range("A1")
End Sub

-- 
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Back to comp.lang.basic.visual.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Can't select a range of data/single cell ACE <aenten1@gmail.com> - 2011-07-11 12:34 -0700
  Re: Can't select a range of data/single cell GS <gs@somewhere.net> - 2011-07-11 18:44 -0400
    Re: Can't select a range of data/single cell GS <gs@somewhere.net> - 2011-07-11 18:54 -0400
      Re: Can't select a range of data/single cell GS <gs@somewhere.net> - 2011-07-11 18:56 -0400
        Re: Can't select a range of data/single cell ACE <aenten1@gmail.com> - 2011-07-12 08:45 -0700
          Re: Can't select a range of data/single cell GS <gs@somewhere.net> - 2011-07-12 11:50 -0400

csiph-web