VBA Code and merging cells

siddhu1234

New Member
Joined
Dec 8, 2021
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
Hai guys ,

I am working a new store management for my form , in this light i have created a few user forms to capture the data into excel,while doing so i was badly struck at one point if you see the below excel sheet containing the column heads as below


Supplier NameSupplier AddressCityCountryPostal CodeMail IDFax NoMobile NoContact personDesignationMaterial
fsdfsdf
fsdfsdf
fsfsdfs
M/s Makrocastsfsdfsdfsfsdfsdfdsdfsdf
32323​
Siddhuprince@gmail.com
8878​
8768786​
hjghsgjhafsdfsdfsfdsdfsf

If we see here these are the details i have captured from the user-form which i have created , when you see the above excel i have the material column which is having details of the different materials, but the supplier details or any other details have been captured in one row , here how can i use a VBA code to merge the empty rows as above under individual column,
This sequence will be happening every 4 rows once , i am sending my excel sheet also for reference
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I recommand that you DON'T merge cells, but you fill the rows with the full information.
You can do that with the following macro:
VBA Code:
Sub Normalize()
Dim DaCol As String, LastFull As Range
'
DaCol = "A"                     '<<< "Supplier Name" column
Application.EnableEvents = False
For I = Cells(Rows.Count, DaCol).End(xlUp).Row To 2 Step -1
    If Cells(I, DaCol).Value = "" And Cells(I, DaCol).Offset(0, 10) <> "" Then
        If Not LastFull Is Nothing Then
            LastFull.Copy Cells(I, DaCol)
        End If
    Else
        Set LastFull = Cells(I, DaCol).Resize(1, 11)
    End If
Next I
Application.CutCopyMode = False
Application.EnableEvents = True
End Sub
This will work on the active sheet; the macro will start from the last compiled row in the specified column (see the line marked <<<), and will go backward coping its data to the previuos empty rows. This will work an the whole worksheet, not only on the last block.
If you wish, you may call this macro at the end of your process, adding the line Call Normalize to your code

Bye
 
Upvote 0
Solution

Forum statistics

Threads
1,215,022
Messages
6,122,716
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top