+ Reply to Thread
Results 1 to 8 of 8

EXCEL: How To Get The Column Number From Where The Cell Is Copied.

  1. #1
    Forum Contributor
    Join Date
    12-28-2012
    Location
    Mumbai - India
    MS-Off Ver
    Excel
    Posts
    145

    EXCEL: How To Get The Column Number From Where The Cell Is Copied.

    Goal: To get the column number from where we have copied a particular CELL

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: EXCEL: How To Get The Column Number From Where The Cell Is Copied.

    Hi Gaikwad,

    You can store the column number in a variable "i" using below code:-

    Please Login or Register  to view this content.
    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Forum Contributor
    Join Date
    12-28-2012
    Location
    Mumbai - India
    MS-Off Ver
    Excel
    Posts
    145

    Re: EXCEL: How To Get The Column Number From Where The Cell Is Copied.

    Thanks Dilip,

    I' ll tell you my actual requirement,

    I' am using a code where I' have blocked many copy paste scenario. but now I' want to allow user to copy paste within a single column.

    example:

    as per my code if I' copy content from A1 it will not paste in B1, C1 or any other Cell even in A2.

    Now I' want to change it like if I' copied from A1 then it should paste in A2, A3, A4, or any other cells in the same column.

    please help me with this

    Thanks

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: EXCEL: How To Get The Column Number From Where The Cell Is Copied.

    Okay.. so I believe, you can simply use range("a2").pastespecial.


    Regards,
    DILIPandey
    <click on below * if this helps>

  5. #5
    Forum Contributor
    Join Date
    12-28-2012
    Location
    Mumbai - India
    MS-Off Ver
    Excel
    Posts
    145

    Re: EXCEL: How To Get The Column Number From Where The Cell Is Copied.

    Did Get You....

    Could you please give me the Code for the same.

  6. #6
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: EXCEL: How To Get The Column Number From Where The Cell Is Copied.

    Already given code line in my post #4 ...


    Regards,
    DILIPandey
    <click on below * if this helps>

  7. #7
    Forum Contributor
    Join Date
    12-28-2012
    Location
    Mumbai - India
    MS-Off Ver
    Excel
    Posts
    145

    Re: EXCEL: How To Get The Column Number From Where The Cell Is Copied.

    I need code as below:

    If Cell is copied from Column Number ex:10 [same sheet] Then
    It Can be paste any Cell in the column 10
    Else
    My conditional Code.
    End If


    ##### How to write this???? #####

  8. #8
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: EXCEL: How To Get The Column Number From Where The Cell Is Copied.

    Okay..
    First, you need to decide what you need - are you controlling the user's action -> Y/N

    If Y, then you need to do it using worksheet change / selection change events
    If N, then its you who would be creating the code and hence create the code as you want

    so for copying the data in column A and paste in Column A only
    like :-

    Range("a1").copy
    Range("a2").pastespeical

    Above code will copy data in column A and will paste in column A - because thats the way it has been written .. hope this is clear to you now. Thx


    Regards,
    DILIPandey
    <click on below * if this helps>

+ 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