+ Reply to Thread
Results 1 to 9 of 9

switching fields automatically

Hybrid View

  1. #1
    Registered User
    Join Date
    09-25-2007
    Location
    Singapore
    Posts
    15
    i have the same question here too.

    What if i want to switch from row d8 to d1 automatically using code?

    i know manually it can be done.

    Any idea how?

    Your reply will be a great help!
    thinkthinkthinkthink
    burst brains with macro vb codes
    http://www.excelforum.com/showthread.php?t=584092

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Hi macroDummy,

    In the future please create a new thread and reference this one.

    As for your query, do you want to switch the values in D8 and D1, or do you just want to move the value in D8 to D1?

    To switch, this code would suffice:
    Sub switchCells()
        Dim rng1 As Variant
        rng1 = Range("D1")
        Range("D1") = Range("D8")
        Range("D8") = rng1
    End Sub

  3. #3
    Registered User
    Join Date
    09-25-2007
    Location
    Singapore
    Posts
    15
    Hi

    Thank you for your quick response. Ok,next time i will create new thread with the reference.

    Sorry for not being exact.

    What i want is to have values in D8 switch with the values in D1.

    I will try implanting your codes right now.

    Regards,
    Lily

  4. #4
    Registered User
    Join Date
    09-25-2007
    Location
    Singapore
    Posts
    15
    The results give me a blank on row D1.

    Values in D1 to D8 successfully being switched.

    But values in D8 to D1 is blank.

    Regards,
    Lily

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Just for reference, what is the value in D1 and what is the value in D8? And are they text? Stored as text? Numeric?

    I've tried a dozen different values, text strings, etc. and each time I run the code it switches the two cells perfectly.

  6. #6
    Registered User
    Join Date
    09-25-2007
    Location
    Singapore
    Posts
    15
    Hmm.

    I don't know where i get it wrong.

    Values in D1 and D8 are mixed of numbers and text.

    Anyway, for your reference, here is what it looked like.

    switch D8 to D1.zip

    switch D8 to D1[part2].zip

    Thank you pjoaquin.

    Very much appreciated.

    Regards,
    Lily

+ 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