+ Reply to Thread
Results 1 to 9 of 9

Target Address after merging cells

  1. #1
    Registered User
    Join Date
    01-23-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    79

    Target Address after merging cells

    On Merging two cells (let's say B2 & C2) we get data in one cell (let's say B2).So, When I write a code for B2 target for Worksheet Selection event. It gives error Because it is taking target as Range B2:C2. What should I do?

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Target Address after merging cells

    Instead of Target Use Target.Cells(1) which will target the first cell of target cell


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Target Address after merging cells

    Hi, tanvi_kalra,

    a very good example why to avoid MergedCells, isnīt it?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    01-23-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    79

    Re: Target Address after merging cells

    Thanks
    It works by using
    Target.Cells(1).Address instead of Target.Address

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Target Address after merging cells

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Target Address after merging cells

    Instead of merging cells, it would be better if you formatted B2:C2 and just used
    Format Cells\Alignment\Horizontal: center across selection

    Then you wouldn't have the issues with merged cells.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  7. #7
    Registered User
    Join Date
    01-23-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    79

    Re: Target Address after merging cells

    Hi Sixthsense

    Already marked it as solved and added reputation too..
    Thanks Again

  8. #8
    Registered User
    Join Date
    01-23-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    79

    Re: Target Address after merging cells

    Re: Target Address after merging cells
    Instead of merging cells, it would be better if you formatted B2:C2 and just used
    Format Cells\Alignment\Horizontal: center across selection

    Then you wouldn't have the issues with merged cells.
    Surround your VBA code with code tags e.g.;
    Please Login or Register  to view this content.
    The pound # icon in the forum editor will apply the code tags around the selected text.
    Already tried that also. But i need to capture the cell value for the code . So , Cell value can be captured from one cell at a time.

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Target Address after merging cells

    Quote Originally Posted by tanvi_kalra View Post
    Already tried that also. But i need to capture the cell value for the code . So , Cell value can be captured from one cell at a time.

    I don't follow what that means, but as long as you have it working now, that's what counts.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Worksheet_Change(ByVal Target As Range) - set to only update when 3 target cells changed?
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2012, 06:40 PM
  2. Target.Address help
    By gth667h in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2010, 05:54 PM
  3. Target.address
    By esullivan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2010, 09:36 AM
  4. Merging and formatting text cells for address
    By william84 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2009, 09:57 AM
  5. Target Address
    By bforster1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2005, 10:21 AM

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