+ Reply to Thread
Results 1 to 4 of 4

Reducing length of code

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Reducing length of code

    can the following code be written in one line?

    Sheets("SC-Author ranking").Cells(j, LastColumnSc + 7) = Sheets("Author ranking").Cells(k, LastColumn - 4) - Sheets("SC-Author ranking").Cells(j, LastColumnSc - 2)
    If Sheets("SC-Author ranking").Cells(j, LastColumnSc + 7) = 0 Then Sheets("SC-Author ranking").Cells(j, LastColumnSc + 7) = ""
    Last edited by dschmitt; 05-09-2010 at 10:23 PM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: problem with reducing lenght of code

    Hi dschmitt
    maybe as good start to reduce would be
    With Sheets("SC-Author ranking")
    .Cells(j, LastColumnSc + 7) = .Cells(k, LastColumn - 4) - .Cells(j, LastColumnSc - 2)
    If .Cells(j, LastColumnSc + 7) = 0 Then .Cells(j, LastColumnSc + 7) = ""
    End With
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: problem with reducing lenght of code

    so, you are saying it can not be written in one line? Is that correct?

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: problem with reducing lenght of code

    try
    Sheets("SC-Author ranking").Cells(j, LastColumnSc + 7) = Sheets("Author ranking").Cells(k, LastColumn - 4) - Sheets("SC-Author ranking").Cells(j, LastColumnSc - 2):If Sheets("SC-Author ranking").Cells(j, LastColumnSc + 7) = 0 Then Sheets("SC-Author ranking").Cells(j, LastColumnSc + 7) = ""

+ 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