'How do I merge cells by using a variable
Hi, I wish to merge these range of cells together but it does not work. No error pops out. nextEmptyCellA is the next empty Cell before values are input into the list, and endEmptyCellA is the next empty cell after the values are input into the list. The values are input in another column and i wish to merge the cells in another column, corresponding the the numbers of value inputted.
This is the code: With sh
Dim nextEmptyCellA As Range
Set nextEmptyCellA = Range("A" & Rows.Count).End(xlUp).Offset(1)
Dim nextEmptyCellB As Range
Set nextEmptyCellB = Range("B" & Rows.Count).End(xlUp).Offset(1)
Dim nextEmptyCellC As Range
Set nextEmptyCellC = Range("C" & Rows.Count).End(xlUp).Offset(1)
If addForm.xs = True Then
Range("C" & Rows.Count).End(xlUp).Offset(1) = "XS"
Range("D" & Rows.Count).End(xlUp).Offset(1) = addForm.qxs
Range("E" & Rows.Count).End(xlUp).Offset(1) = addForm.qxs
End If
If addForm.s = True Then
Range("C" & Rows.Count).End(xlUp).Offset(1) = "S"
Range("D" & Rows.Count).End(xlUp).Offset(1) = addForm.qs
Range("E" & Rows.Count).End(xlUp).Offset(1) = addForm.qs
End If
If addForm.m = True Then
Range("C" & Rows.Count).End(xlUp).Offset(1) = "M"
Range("D" & Rows.Count).End(xlUp).Offset(1) = addForm.qm
Range("E" & Rows.Count).End(xlUp).Offset(1) = addForm.qm
End If
If addForm.l = True Then
Range("C" & Rows.Count).End(xlUp).Offset(1) = "L"
Range("D" & Rows.Count).End(xlUp).Offset(1) = addForm.ql
Range("E" & Rows.Count).End(xlUp).Offset(1) = addForm.ql
End If
If addForm.xl = True Then
Range("C" & Rows.Count).End(xlUp).Offset(1) = "XL"
Range("D" & Rows.Count).End(xlUp).Offset(1) = addForm.qxl
Range("E" & Rows.Count).End(xlUp).Offset(1) = addForm.qxl
End If
If addForm.xxl = True Then
Range("C" & Rows.Count).End(xlUp).Offset(1) = "XXL"
Range("D" & Rows.Count).End(xlUp).Offset(1) = addForm.qxxl
Range("E" & Rows.Count).End(xlUp).Offset(1) = addForm.qxxl
End If
If addForm.standardSize = True Then
Range("C" & Rows.Count).End(xlUp).Offset(1) = "Standard Size"
Range("D" & Rows.Count).End(xlUp).Offset(1) = addForm.qstandardSize
Range("E" & Rows.Count).End(xlUp).Offset(1) = addForm.qstandardSize
End If
Cells(nextEmptyCellC.Row, 1) = addForm.plusItem
Dim endEmptyCellA As Range
Set endEmptyCellA = Range("A" & Rows.Count).End(xlUp).Offset(1)
Range("A" & nextEmptyCellA.Row, "A" & endEmptyCellA.Row).Merge
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|