VBA: Quickly Merge Cells with Same Values in Excel

Поділитися
Вставка
  • Опубліковано 9 лют 2025
  • #MergeSameCells #VBAtutorial #ExcelTips
    Hello Friends,
    In this video you will learn how to merge cells with same values in Excel using VBA. This is a time saving trick. You can copy this code to your personal macro so that it can be available for each workbook.
    Please download this excel file from below given link:
    www.pk-anexcel...
    Download our free Excel utility Tool and improve your productivity:
    www.pk-anexcel...
    See our Excel Products:
    www.pk-anexcel...
    Visit to learn more:
    Chart and Visualizations: www.pk-anexcel...
    VBA Course: www.pk-anexcel...
    Download useful Templates: www.pk-anexcel...
    Dashboards: www.pk-anexcel...
    Watch the best info-graphics and dynamic charts from below link:
    • Dynamic Graphs
    Learn and free download best excel Dashboard template:
    • Excel Dashboards
    Learn Step by Step VBA:
    • VBA Tutorial
    Website:
    www.PK-AnExcel...
    Facebook:
    / pkanexcelexpert
    Telegram:
    t.me/joinchat/...
    Twitter:
    / priyendra_kumar
    Pinterest:
    / pkanexcelexpert
    Send me your queries on telegram:
    @PKanExcelExpert
    ************ Suggested Books ********
    VBA: amzn.to/2TMMikX
    Excel Dashboard: amzn.to/2WZi2Fj
    Power Query: amzn.to/2Ibd7xR
    Power Pivot and Power BI: amzn.to/2DCg8BB
    Exam Ref 70-778 (Power BI): amzn.to/2GnWYTN
    ************ My Stuff ***************
    Mic : amzn.to/2TLnF88
    Video Editor: screencast-o-m...

КОМЕНТАРІ • 193

  • @anandkishore9
    @anandkishore9 5 років тому +10

    Thank you Sir. The code was explained in very simple and easy to understand way. Please keep it up.

  • @elliotthopkins8661
    @elliotthopkins8661 3 роки тому +3

    Amazing, exactly what I was looking for. Thank you!

  • @gl_coimbra
    @gl_coimbra 2 місяці тому +1

    Thank you so much! Ended up downloading your AddIn

  • @jebingeorge9698
    @jebingeorge9698 3 роки тому +1

    Thank You sir. You saved me a lot of time. especially by providing the code.

  • @misalee433
    @misalee433 4 роки тому +2

    I was struggling on this issue today, this helped me very much. thanks :)

  • @phimiuniu
    @phimiuniu Рік тому +1

    Super helpful. Thank you!

  • @Ruqqayahzahra.123
    @Ruqqayahzahra.123 Рік тому +1

    I was searching for this thanks 🎉🎉🎉

  • @atulbharti7880
    @atulbharti7880 Місяць тому +1

    Sir,You are the only youtuber who give and teach Vba code properly and also tell us how it works step by step.Other just say link in description box you can get from there.Hats off to u sir🫡🫡

  • @BryanSeigneur0
    @BryanSeigneur0 4 роки тому

    Thank God the main part of this program is only a few lines long and also for you starting with the main part. Also thank you for demonstrating the script at the beginning. This is a great thing for spreadsheets to be able to do to make data clearer. It should be a standard function.
    I've often wanted this for many things. I am using it now for query results, kind of a quick and dirty grouping report for my own use. It makes the data VERY VERY much each easier to see and find what I'm looking for.

  • @NgocNguyen-oc6ow
    @NgocNguyen-oc6ow 3 роки тому +1

    it's very useful, thanks a lot. You got my subscription.

  • @murtazaiqbal7267
    @murtazaiqbal7267 5 років тому +2

    Wow... Thank you so much... It helps a lot... I want to organize data which is in 1000s and was searching for efficient way to group and order by specific range and here it is... Simply outstanding and easy..😊👍

  • @thatzevy
    @thatzevy 3 роки тому +1

    LIFE SAVER! THANK YOU!

  • @queuedreads
    @queuedreads 4 роки тому

    Thank you so much for this!! You just saved me from 800 rows of data!! Cheers!

  • @raissaveneziaborba8230
    @raissaveneziaborba8230 4 роки тому +2

    Thank you so much!!! Keep the good job ;)

  • @vinachatte
    @vinachatte Рік тому +1

    Thanks! very helpful!

  • @galaxialove369
    @galaxialove369 Рік тому +1

    You are the best!

  • @pandharinathjoshi6565
    @pandharinathjoshi6565 10 місяців тому +1

    Sir i have seen this video sir
    Actually exact need this one sir
    Its very usefull sir

  • @sureshchand2393
    @sureshchand2393 3 роки тому +1

    Thank you Sir, It was really helpful for me.

  • @bbiggie97
    @bbiggie97 3 роки тому

    You're the best, thanks for the tutorial.

  • @VillaOuk
    @VillaOuk 3 роки тому +1

    Thanks very much. Cool trick

  • @Misicuni20
    @Misicuni20 3 роки тому

    this is amazing!!! Thank you so much for your help and offer to download. It works perfectly

  • @qatar-hd4709
    @qatar-hd4709 3 роки тому +1

    Thank you so much , it works perfect 👍👍👍

  • @Agapeisthebest
    @Agapeisthebest 4 роки тому +1

    Your channel is amazing!!!!! Thanks for sharing well explained, quality content.

  • @nizarhasanbisri8758
    @nizarhasanbisri8758 Рік тому +1

    Super helpfull!!! thank you

  • @jepnkd
    @jepnkd 3 роки тому +1

    Great tips thank you

  • @ExcelMadeEasy444
    @ExcelMadeEasy444 5 років тому +1

    Excellent !!! Great Job.

  • @ruchidahiya4260
    @ruchidahiya4260 3 роки тому +1

    Thankyou...helped me a lot

  • @m.mahesh2155
    @m.mahesh2155 Рік тому +1

    Super explanation👍👍👍👍🎂🎂🎂🌹🌹🌹🌹

  • @ishtiaqkhan1832
    @ishtiaqkhan1832 3 роки тому +1

    very nice tutorial

  • @Saatt79
    @Saatt79 5 років тому +1

    Awesome one sir as usual 👏👏👏

  • @matrva
    @matrva Рік тому +1

    Good one!

  • @vascomartins2654
    @vascomartins2654 Рік тому

    You're the goat!

  • @tirumalareddynagarsachival1091
    @tirumalareddynagarsachival1091 4 роки тому +1

    THANK YOU FOR YOUR HELP

  • @joeheldelrosario461
    @joeheldelrosario461 4 роки тому +1

    Very helpful. Thank you

  • @MohAboAbdo
    @MohAboAbdo 5 років тому +1

    Thank you very much for this great video and for this excellent explanation.

  • @sevakbhargav
    @sevakbhargav 3 роки тому +1

    Out standing

  • @chalaava
    @chalaava Рік тому +1

    thanks!

  • @SyedMuzammilMahasanShahi
    @SyedMuzammilMahasanShahi 5 років тому +1

    Beautiful work as usual. Thanks for the share.

  • @Leo-ec3rq
    @Leo-ec3rq 2 роки тому

    Great thank you! still so useful

  • @Deepak726verma
    @Deepak726verma 2 роки тому +1

    Thanks a lots.

  • @KL6400
    @KL6400 5 років тому +1

    Thank you sir🤩 Very useful tool!

  • @sehlebasheer4709
    @sehlebasheer4709 4 роки тому +1

    Can we do it with Power Query

  • @gilberto00
    @gilberto00 4 роки тому +1

    Amazing instructions. Thanks, man!

  • @sasavienne
    @sasavienne 5 років тому +1

    Simply great. Thank you so much.

  • @mrisnaini4631
    @mrisnaini4631 4 роки тому

    thank you for sharing knowledge is very helpful

  • @marjmoniquecabical9341
    @marjmoniquecabical9341 2 роки тому +3

    under the code "If rng.Value = rng.Offset(1, 0).Value And rng.Value "" Then", excel shows error 1004, that is, rng.value is neither application-defined or object defined; rng.Value = empty. Please help.

  • @tugrulbozbey9700
    @tugrulbozbey9700 4 роки тому +1

    Thank you, it works.

  • @9181shreyasbhatt
    @9181shreyasbhatt 5 років тому +1

    Very helpful. Thank you very much.

  • @TamilMoviesQuiz
    @TamilMoviesQuiz 4 роки тому +1

    Sir, that's really good. My requirement is different, I want to merge rows (different data) in one cell (looks like rows only) without losing any data.

  • @VishalSharma-rn7mt
    @VishalSharma-rn7mt 5 років тому +2

    great video thank you so much for this solution.

  • @TheBaljeet123
    @TheBaljeet123 2 роки тому

    Can we use this for date column
    And One more thing i want that i want to sum the value in another column....plz help

  • @hafijul233
    @hafijul233 3 роки тому

    Thank you. Excel file need to be .xlsm format to work

  • @Anik2024-o5m
    @Anik2024-o5m 4 роки тому +1

    Thanks a ton, subscribing your channel for this video.

    • @PKAnExcelExpert
      @PKAnExcelExpert  4 роки тому +1

      Thanks for watching and subscribing. Welcome 🙏

  • @scitcivil7623
    @scitcivil7623 3 місяці тому

    Sir I want to fill the data to the right and merge to the right how can I do t can you explain it sir

  • @siddhuprince1
    @siddhuprince1 3 роки тому

    Thank You very much , code neat and clear, i have query, suppose if we have one row of column with value, next 3 rows blank, any after the blank row one more rows starts with another different value, and this continues for every 3 blank rows a new row with details is present in the sheet, then how to merge with VBA

  • @rhondabrown5532
    @rhondabrown5532 3 роки тому +3

    Thank you, your tutorial is very helpful. How would you change the macro if you want the merge to be across columns? My range would be from Col. J to Col. BI and I would like to combine (consecutive) cells wit the same input data.

  • @lucasrossi1175
    @lucasrossi1175 4 роки тому

    Excellent!

  • @samnangsuonsokunth8719
    @samnangsuonsokunth8719 Рік тому

    sir can we merge with out selection vba?

  • @mdazheralikhan7685
    @mdazheralikhan7685 4 роки тому

    Thank you for explaining the code, it was really helpful. One small question incase if I need to add totals here what should be done

  • @sandeepkumar-cx4or
    @sandeepkumar-cx4or 5 років тому +1

    thank a lot of you for sharing this

  • @Monir7034
    @Monir7034 3 роки тому

    very good..

  • @khaledsaleh8604
    @khaledsaleh8604 5 років тому +1

    Good work
    Thank you

  • @kapilm6837
    @kapilm6837 4 роки тому

    This has helped me a lot but how to have sum of total for merge cells in next column against each merge cell

  • @AbijithVP-m4i
    @AbijithVP-m4i 4 місяці тому

    Hy, i have a question. If the values in the first column is in disorder(in your excel if January is comes again after February) can we use this program??

  • @koushikkumarroychowdhury1034
    @koushikkumarroychowdhury1034 2 роки тому

    Can we sum it in the last column based on First column criterion?

  • @snowyseptember1610
    @snowyseptember1610 5 років тому +1

    Thanks a lot Sir, that's really helpful

  • @admingb1123
    @admingb1123 2 роки тому

    Nice sir, is it possible in google sheet? plz reply

  • @ghazwankhalid
    @ghazwankhalid 4 роки тому +1

    Thank You bro.

  • @rickkeev4919
    @rickkeev4919 5 років тому

    Good vid; thanks for sharing. It would have been nice to include the reverse (unmerge)

  • @dianari1457
    @dianari1457 4 роки тому +1

    thanks so much!!

  • @hussenshakoor
    @hussenshakoor 4 роки тому +1

    thank you so much , i love you

  • @taruntyagi12
    @taruntyagi12 4 роки тому

    Realy helpful

  • @patkartarun
    @patkartarun 4 роки тому

    Thanks alot

  • @nelsonalva
    @nelsonalva 4 роки тому

    My man!

  • @raghavendranl
    @raghavendranl 3 роки тому

    Sir, it's helped lot to me. Thank you. Can I use same formula in Google spread sheets. Phase reply me.

  • @khairulaznal8769
    @khairulaznal8769 3 роки тому

    but does it have to run every time I open excel because it seems like it needs to run again once I close it and open it again

  • @ibm98852
    @ibm98852 5 років тому +1

    Thanks for useful video...
    How can we add a blank row in each merged cell. Sometime we have only one cell, so need not merge it but need blank row in between two rows.
    Thanks in advance

  • @metasol7477
    @metasol7477 5 років тому +3

    Useful!! However, I come to a problem with this-it will only merge cell that are in order. How about a modified macro where you can merge cells not in order? For example: January, March, January, February, March data order. Thanks

    • @sharathnb
      @sharathnb 3 роки тому

      I think then, we have to first sort the column in ascending or descending order and then apply VB

  • @JaimaocantaJaimao
    @JaimaocantaJaimao 3 роки тому

    Thank you PK this is so valuable! Subscribed immediately. What if I wanted to also merge blank cells?

  • @rituparnachatterjee713
    @rituparnachatterjee713 3 роки тому

    Hello, is there is any formula which I can use instead of VBA for marging the data. Plz inform

  • @majidsiddique8227
    @majidsiddique8227 5 років тому

    Excellent

  • @trojan211281
    @trojan211281 3 роки тому +2

    Excellent... thanks a lot. It is extremely useful and I was searching for something exactly like this. Just a question, will it do sorting the whole rows as well ? Like in your example if another pk was at the last of the column, would it bring it up and then do the merge ?

  • @danishhaider101
    @danishhaider101 4 роки тому +1

    thanks sir

  • @byahmohammed6849
    @byahmohammed6849 5 років тому +1

    thaank you sir , that's so helpful

    • @PKAnExcelExpert
      @PKAnExcelExpert  5 років тому

      Thanks for your appreciation. Request you to please share this with your friends and colleagues.

  • @kirbyallen8396
    @kirbyallen8396 2 роки тому

    Is there a way for me to have borders around the merged lines after it is seperated? For example, there would be a new border line between January, Feb, etc. from this code that would show up after the merge?

    • @PKAnExcelExpert
      @PKAnExcelExpert  2 роки тому

      Yes, we can create border. need to a piece of code accordingly

  • @Nevir202
    @Nevir202 Рік тому

    So, tried this and a few other scripts too, every single thing just throws errors about ';' expected.
    Anyone know what's up with that?

  • @AN-yj9qv
    @AN-yj9qv 2 роки тому

    How do a create the macro it says error

  • @archanaaa2514
    @archanaaa2514 4 роки тому

    Sir, I am beginner to vba.. As a beginner how much we need to learn in vba code part? Wat we must knw

  • @abdulrehmanaltaf9504
    @abdulrehmanaltaf9504 5 років тому +1

    thanks dear... wow...

  • @pascualmorante2687
    @pascualmorante2687 2 роки тому

    Help, It says compile error "Label not define" then the GoTo Mergecells are highlightened

  • @Bangladesh689
    @Bangladesh689 3 роки тому

    How to do the same thing on MS word?

  • @aniruddhamukherjee6146
    @aniruddhamukherjee6146 4 роки тому

    what version of excel should we have to use developer option and all

    • @PKAnExcelExpert
      @PKAnExcelExpert  4 роки тому +1

      Developer Tab is available in Excel 2007 and above versions. You need enable this. Please watch below video-
      ua-cam.com/video/q8AZ2TGbY7M/v-deo.html

  • @GaneshSutar-mf7bs
    @GaneshSutar-mf7bs Рік тому

    How to Unmerge once data changed from similar range

  • @airjentzen7406
    @airjentzen7406 5 років тому

    I am currently using this macro and transposing it when I'm finished. How would you change the Macro to merge same cells within rows instead of columns. Thanks!

    • @johnny51981
      @johnny51981 4 роки тому

      AIRJENTZEN I just played around with this, as this video got me on the perfectly correct path. To merge horizontally (as opposed to the displayed vertically), simply invert all 4 of the (1, 0) to read (0, 1).

  • @muthurajmmuthu1839
    @muthurajmmuthu1839 3 роки тому

    Could you please give me code for unmering cells and repeat the values of merged cells

  • @jagannathan4750
    @jagannathan4750 Рік тому

    Why it's not working for rows merging?

  • @mohamedseda3735
    @mohamedseda3735 2 роки тому

    How to avoid null fill for a cell after merging multiple cells
    As we I make a filter it looks at the merged cell as empty, however i don't want that

  • @AngelStickman
    @AngelStickman 4 роки тому

    I don't know what changed since you made this but this loop crashes on me. Either it doesn't stop and is merging empty cells or it merges everything correctly then crashes at the if statement when it runs out of values. Its not very robust.

  • @alexandergonzalojimenezcas3984
    @alexandergonzalojimenezcas3984 5 років тому

    ME ENCANTO PODRIA AYUDARME QUIERO COPIAR VALORES DE ACUERDO AL CHECK DE REVISION Y QUE SOLO ME COPIE ESOS VALORES QUE ESTAN CON EL CHECK A OTRA HOJA PLEASE

  • @shaikhaziz9703
    @shaikhaziz9703 4 роки тому

    sir, i want to merge column based on first value
    e.g. in columnA (A2) i have numric value something 50 and after 40 blank rows i have another value like 60, and so on:
    please suggest any code