+ Reply to Thread
Results 1 to 5 of 5

Syntax problem

  1. #1
    Registered User
    Join Date
    08-25-2005
    Posts
    5

    Syntax problem

    Can anyone debug this?

    Sub TransposeData3()
    sr = 1
    dr = 0
    For sr = 1 To 29 Step 10 ' Change 100 to suit number of rows in the source
    Column
    dr = dr + 1
    Range(Cells(sr, 1), Cells(sr + 9, 1)).Select ' Select A1:A19 first
    loop, then A11:A20 next loop etc
    Selection.Copy
    Cells(dr, 2).Select ' Select B1 first loop, then B2 second loop etc
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
    SkipBlanks:= _
    False, Transpose:=True
    Next
    End Sub

  2. #2
    Tom Ogilvy
    Guest

    Re: Syntax problem

    Sub TransposeData3()
    sr = 1
    dr = 0
    rw = Cells(Rows.Count, sr).End(xlUp)
    For sr = 1 To rw + 9 Step 10
    dr = dr + 1
    Range(Cells(sr, 1), Cells(sr + 9, 1)).Select
    Selection.Copy
    Cells(dr, 2).Select
    Selection.PasteSpecial _
    Paste:=xlPasteAll, _
    Operation:=xlNone, _
    SkipBlanks:=False, _
    Transpose:=True
    Next
    End Sub

    --
    Regards,
    Tom Ogilvy
    "unknowndevice" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Can anyone debug this?
    >
    > Sub TransposeData3()
    > sr = 1
    > dr = 0
    > For sr = 1 To 29 Step 10 ' Change 100 to suit number of rows in the
    > source
    > Column
    > dr = dr + 1
    > Range(Cells(sr, 1), Cells(sr + 9, 1)).Select ' Select A1:A19
    > first
    > loop, then A11:A20 next loop etc
    > Selection.Copy
    > Cells(dr, 2).Select ' Select B1 first loop, then B2 second loop
    > etc
    > Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
    > SkipBlanks:= _
    > False, Transpose:=True
    > Next
    > End Sub
    >
    >
    > --
    > unknowndevice
    > ------------------------------------------------------------------------
    > unknowndevice's Profile:

    http://www.excelforum.com/member.php...o&userid=26646
    > View this thread: http://www.excelforum.com/showthread...hreadid=399610
    >




  3. #3
    Doug Glancy
    Guest

    Re: Syntax problem

    unknowndevice,

    I think you may be expecting different results from the "step 10" portion of
    your for loop than what you'll actually get. E.g.,

    Dim i As Long
    For i = 1 To 29 Step 10
    Debug.Print i
    Next i

    results in 1, 11 and 21 whereas it looks like you're expecting 10, 20, 30
    ....

    hth,

    Doug

    "unknowndevice" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Can anyone debug this?
    >
    > Sub TransposeData3()
    > sr = 1
    > dr = 0
    > For sr = 1 To 29 Step 10 ' Change 100 to suit number of rows in the
    > source
    > Column
    > dr = dr + 1
    > Range(Cells(sr, 1), Cells(sr + 9, 1)).Select ' Select A1:A19
    > first
    > loop, then A11:A20 next loop etc
    > Selection.Copy
    > Cells(dr, 2).Select ' Select B1 first loop, then B2 second loop
    > etc
    > Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
    > SkipBlanks:= _
    > False, Transpose:=True
    > Next
    > End Sub
    >
    >
    > --
    > unknowndevice
    > ------------------------------------------------------------------------
    > unknowndevice's Profile:
    > http://www.excelforum.com/member.php...o&userid=26646
    > View this thread: http://www.excelforum.com/showthread...hreadid=399610
    >




  4. #4
    Tom Ogilvy
    Guest

    Re: Syntax problem

    Think you are misreading the intent of the code. Printing out Sr and Area
    to be transpose:

    1 $A$1:$A$10
    11 $A$11:$A$20
    21 $A$21:$A$30
    31 $A$31:$A$40
    41 $A$41:$A$50

    --
    Regards,
    Tom Ogilvy

    "Doug Glancy" <[email protected]> wrote in message
    news:%[email protected]...
    > unknowndevice,
    >
    > I think you may be expecting different results from the "step 10" portion

    of
    > your for loop than what you'll actually get. E.g.,
    >
    > Dim i As Long
    > For i = 1 To 29 Step 10
    > Debug.Print i
    > Next i
    >
    > results in 1, 11 and 21 whereas it looks like you're expecting 10, 20, 30
    > ...
    >
    > hth,
    >
    > Doug
    >
    > "unknowndevice"

    <[email protected]>
    > wrote in message
    > news:[email protected]...
    > >
    > > Can anyone debug this?
    > >
    > > Sub TransposeData3()
    > > sr = 1
    > > dr = 0
    > > For sr = 1 To 29 Step 10 ' Change 100 to suit number of rows in the
    > > source
    > > Column
    > > dr = dr + 1
    > > Range(Cells(sr, 1), Cells(sr + 9, 1)).Select ' Select A1:A19
    > > first
    > > loop, then A11:A20 next loop etc
    > > Selection.Copy
    > > Cells(dr, 2).Select ' Select B1 first loop, then B2 second loop
    > > etc
    > > Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
    > > SkipBlanks:= _
    > > False, Transpose:=True
    > > Next
    > > End Sub
    > >
    > >
    > > --
    > > unknowndevice
    > > ------------------------------------------------------------------------
    > > unknowndevice's Profile:
    > > http://www.excelforum.com/member.php...o&userid=26646
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=399610
    > >

    >
    >




  5. #5
    Doug Glancy
    Guest

    Re: Syntax problem

    Tom,

    I think you're right.

    Thanks,

    Doug

    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > Think you are misreading the intent of the code. Printing out Sr and Area
    > to be transpose:
    >
    > 1 $A$1:$A$10
    > 11 $A$11:$A$20
    > 21 $A$21:$A$30
    > 31 $A$31:$A$40
    > 41 $A$41:$A$50
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Doug Glancy" <[email protected]> wrote in message
    > news:%[email protected]...
    >> unknowndevice,
    >>
    >> I think you may be expecting different results from the "step 10" portion

    > of
    >> your for loop than what you'll actually get. E.g.,
    >>
    >> Dim i As Long
    >> For i = 1 To 29 Step 10
    >> Debug.Print i
    >> Next i
    >>
    >> results in 1, 11 and 21 whereas it looks like you're expecting 10, 20, 30
    >> ...
    >>
    >> hth,
    >>
    >> Doug
    >>
    >> "unknowndevice"

    > <[email protected]>
    >> wrote in message
    >> news:[email protected]...
    >> >
    >> > Can anyone debug this?
    >> >
    >> > Sub TransposeData3()
    >> > sr = 1
    >> > dr = 0
    >> > For sr = 1 To 29 Step 10 ' Change 100 to suit number of rows in the
    >> > source
    >> > Column
    >> > dr = dr + 1
    >> > Range(Cells(sr, 1), Cells(sr + 9, 1)).Select ' Select A1:A19
    >> > first
    >> > loop, then A11:A20 next loop etc
    >> > Selection.Copy
    >> > Cells(dr, 2).Select ' Select B1 first loop, then B2 second loop
    >> > etc
    >> > Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
    >> > SkipBlanks:= _
    >> > False, Transpose:=True
    >> > Next
    >> > End Sub
    >> >
    >> >
    >> > --
    >> > unknowndevice
    >> > ------------------------------------------------------------------------
    >> > unknowndevice's Profile:
    >> > http://www.excelforum.com/member.php...o&userid=26646
    >> > View this thread:

    > http://www.excelforum.com/showthread...hreadid=399610
    >> >

    >>
    >>

    >
    >




+ 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