+ Reply to Thread
Results 1 to 2 of 2

Simplifying the Code

  1. #1
    Registered User
    Join Date
    05-28-2008
    Posts
    1

    Simplifying the Code

    I have the following VBA code which works fine for me. I'm just wondering if there is a way to simplify it and make it shorter.

    In other words do i need to use the word ".Address" everytime I use the cells(i,j) addressing method.

    Also, the formula that will be placed in cell(21,10) is

    = IF($G$21 <> "y", ABS($C$21)*$D$21/$B$21, "")

    which is what I want but I'm wondedring how can I replace $C$21 with just C21. i.e. how to remove the dollar sign.

    Cells(21, 10) = "= IF(" & Cells(21, 7).Address & " <> ""y"", abs(" & Cells(21, 3).Address & ")*" & Cells(21, 4).Address & "/" & Cells(21, 2).Address & ", """")"

    Thanks folks

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    1) Yes the .address is required if you want to get the address component.

    2) There are a couple of ways.
    (a) use worksheetfunction.substitute to remove the $ sign from the address or
    (b) use the form
    Please Login or Register  to view this content.
    to return the non absoluted address.


    HTH

    rylo

+ 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