+ Reply to Thread
Results 1 to 4 of 4

Alternative vba code

Hybrid View

pezalmendra Alternative vba code 08-01-2013, 06:10 AM
AB33 Re: Alternative vba code 08-01-2013, 06:25 AM
AB33 Re: Alternative vba code 08-01-2013, 06:27 AM
pezalmendra Re: Alternative vba code 08-01-2013, 07:31 AM
  1. #1
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Alternative vba code

    Hello!

    Could someone help me in modifying the bellow code into a similar one?
    There is something I must be doing wrong cause is not running properly...


    For i = 1 To LastArea
    If Sheet20.Cells(3, 2 + 14 * i) = "" Then
    Else
      With Sheet20
      .Range(.Cells(2, "B"), .Cells(6, "N")).Copy Destination:=.Range(.Cells(2, 2 + 14 * i), .Cells(6, 14 + 14 * i))
      .Range(.Cells(2, "B"), .Cells(6, "O")).EntireColumn.Copy
      .Range(.Cells(2, 2 + 14 * i), .Cells(6, 15 + 14 * i)).EntireColumn.PasteSpecial Paste:=xlPasteColumnWidths
      .Cells(3, 2 + 14 * i) = Sheet2.Cells(13 + i, "C").Value
      .Range(.Cells(6, 2 + 14 * i), .Cells(6, 3 + 14 * i)).ClearContents
      .Range(.Cells(6, 7 + 14 * i), .Cells(6, 13 + 14 * i)).ClearContents
      End With
    End If
    Next i

    Thank you very much.

    Kind regards,

    pezal

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Alternative vba code

    Why can not you use a normal cell-range?

    If Sheet20.Cells(3, 2 + 14 * i) = "" Then

    is row 3, column 16 times I, if I =1, you are looking at row3 column 16.
    If you are trying to copy an entire column

    Use
    .Range("B:O").copy
    Instead of

     .Range(.Cells(2, "B"), .Cells(6, "O")).EntireColumn.Copy

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Alternative vba code

    Why can not you use a normal cell-range?

    If Sheet20.Cells(3, 2 + 14 * i) = "" Then

    is row 3, column 16 times I, if I =1, you are looking at row3 column 16.
    If you are trying to copy an entire column

    Use
    .columns("B:O").copy
    Instead of

     .Range(.Cells(2, "B"), .Cells(6, "O")).EntireColumn.Copy

  4. #4
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Alternative vba code

    OK! Thanks!

    Regards

+ 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. [SOLVED] Alternative and faster code
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-07-2013, 09:31 AM
  2. Alternative VBA Code To Paste Special Add
    By John Vieren in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-28-2012, 09:54 AM
  3. Speedier Alternative To Existing Code
    By SamuelT in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-30-2009, 04:55 AM
  4. Alternative code for SumProduct as a VBA function
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-08-2009, 05:07 PM
  5. Alternative Code - Nested Ifs
    By gizoku00 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2008, 11:16 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