Consulting

Results 1 to 3 of 3

Thread: If column F is not empty merge data with column C

  1. #1
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location

    If column F is not empty merge data with column C

    Hello Friends
    I need your help for merge 2 column
    I have Column C and F i need a VBA code that check column F if is not empty merge the data with column C

    Like

    Excel.jpg

    Please help me if you can . Thank you so much for your help

  2. #2
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    The really simple slow way to do this is:

    [VBA]lastrow = sht.Cells(sht.Rows.Count, "C").End(xlUp).Row
    For i = 1 To lastrow
    If Cells(i, 6) <> "" Then
    Cells(i, 3) = Cells(i, 3) & Cells(i, 6)
    End If
    Next i


    [/VBA]

    this is a really slow way of doing this since the vba does multiple accesses to the worksheet. It woulkd be much quicker to use varinat arrays.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    No need to check for empty cells.
    For i = 1 To lastrow 
            Cells(i, 3) = Cells(i, 3) & Cells(i, 6) 
    Next i
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •