+ Reply to Thread
Results 1 to 3 of 3

Shortening Code

  1. #1
    Forum Contributor
    Join Date
    08-20-2005
    Posts
    173

    Shortening Code

    Hi,

    How do I shorten the following:

    sr.Cells(23, 6) = ActiveCell.Offset(1, 0)
    sr.Cells(24, 6) = ActiveCell.Offset(2, 0)
    sr.Cells(25, 7) = ActiveCell.Offset(3, 0)
    sr.Cells(26, 8) = ActiveCell.Offset(4, 0)
    sr.Cells(27, 6) = ActiveCell.Offset(5, 0)
    sr.Cells(28, 6) = ActiveCell.Offset(9, 0)
    sr.Cells(29, 7) = ActiveCell.Offset(12, 0)
    sr.Cells(30, 8) = ActiveCell.Offset(13, 0)
    sr.Cells(31, 6) = ActiveCell.Offset(14, 0)
    sr.Cells(32, 8) = ActiveCell.Offset(15, 0)
    sr.Cells(33, 6) = ActiveCell.Offset(16, 0)
    sr.Cells(34, 6) = ActiveCell.Offset(26, 0)
    sr.Cells(35, 6) = ActiveCell.Offset(24, 0)
    sr.Cells(36, 6) = ActiveCell.Offset(28, 0)
    sr.Cells(37, 6) = ActiveCell.Offset(29, 0)
    sr.Cells(48, 6) = ActiveCell.Offset(6, 0)
    sr.Cells(49, 8) = ActiveCell.Offset(7, 0)
    sr.Cells(50, 7) = ActiveCell.Offset(8, 0)
    sr.Cells(60, 8) = ActiveCell.Offset(17, 0)
    sr.Cells(64, 6) = ActiveCell.Offset(27, 0)
    sr.Cells(72, 6) = ActiveCell.Offset(30, 0)
    sr.Cells(74, 6) = ActiveCell.Offset(10, 0)
    sr.Cells(75, 6) = ActiveCell.Offset(11, 0)
    sr.Cells(164, 8) = ActiveCell.Offset(18, 0)
    sr.Cells(170, 8) = ActiveCell.Offset(21, 0)
    sr.Cells(171, 7) = ActiveCell.Offset(22, 0)


    Regards

  2. #2
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    what r u trying to acheive with code?

    coz depending on exactly what your doing you could prob use a loop

  3. #3
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    You can try with:
    Please Login or Register  to view this content.
    or with:
    Please Login or Register  to view this content.
    May be many other shorter ways as:
    "A1-C25, Z10-F22, AZ5-AB18" etc.

    Regards,
    Antonio

+ 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