Created
March 25, 2021 02:21
-
-
Save quyleanh/3b7bffae5a1981866d02649893370620 to your computer and use it in GitHub Desktop.
Kien_nho.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub ConvertMergedCell() | |
If Selection.MergeCells Then | |
Dim SelAddr As String | |
SelAddr = Selection.Address | |
Selection.Copy | |
Range("GH1").PasteSpecial xlPasteAll | |
Range(SelAddr).Select | |
Selection.UnMerge | |
Dim strTmp As String | |
strTmp = "" | |
Dim i As Integer | |
i = 0 | |
For Each cell In Selection | |
If i = 0 Then | |
strTmp = cell.Value | |
i = i + 1 | |
Else | |
cell.Value = strTmp | |
End If | |
Next cell | |
Range("GH1").MergeArea.Copy | |
Range(SelAddr).PasteSpecial xlPasteFormats | |
Columns("GH").EntireColumn.Delete | |
Else | |
MsgBox "Selection is not a merged cell" | |
End If | |
End Sub | |
Sub FindAllMergedCell() | |
Dim cell As Range | |
For Each cell In ActiveSheet.UsedRange.Cells | |
If cell.MergeCells = True Then | |
cell.Select | |
End If | |
Next cell | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment