I have a macro that I recorded and used in my vb code. It does a center across selection for 3 continguous cells after "combining" the contents of all 3 cells into the first cell separated by a space. Then the values all but the first cell is deleted.
The code works perfectly in excel 2003. I've stored it in my personal.xls.
When copying the same code to an excel user with version 2000 the code doesn't work. It does combine all cell contents into the first cell but it doesn't perform the center across selection.
I recorded the macro in both 2000 and 2003 and the only difference was the .ReadingOrder = xlContext.
I removed this but the same results.
r is the value of the current row.
Here's my code.
If Cells(r, 4).Value <> "" Then
Cells(r, 4).Value = Cells(r, 4).Value & " " & Cells(r, 5).Value & " " & Cells(r, 6).Value
Cells(r, 5).Value = ""
Cells(r, 6).Value = "" 'dont do if blank milestone
myrange = "D" & r & ":" & "F" & r 'range uses row/column letters
Range(myrange).Select
Selection.MergeCells = False 'turn merge off just in case
With Selection
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End If
I'm also experiencing the same problem when trying to do something similar with some date columns but only making them justify right in each column.
here's the code.
myrange = "B" & r & ":" & "C" & r
Range(myrange).Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.NumberFormat = "mm/dd/yy;@"
End With
The code works perfectly in excel 2003. I've stored it in my personal.xls.
When copying the same code to an excel user with version 2000 the code doesn't work. It does combine all cell contents into the first cell but it doesn't perform the center across selection.
I recorded the macro in both 2000 and 2003 and the only difference was the .ReadingOrder = xlContext.
I removed this but the same results.
r is the value of the current row.
Here's my code.
If Cells(r, 4).Value <> "" Then
Cells(r, 4).Value = Cells(r, 4).Value & " " & Cells(r, 5).Value & " " & Cells(r, 6).Value
Cells(r, 5).Value = ""
Cells(r, 6).Value = "" 'dont do if blank milestone
myrange = "D" & r & ":" & "F" & r 'range uses row/column letters
Range(myrange).Select
Selection.MergeCells = False 'turn merge off just in case
With Selection
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End If
I'm also experiencing the same problem when trying to do something similar with some date columns but only making them justify right in each column.
here's the code.
myrange = "B" & r & ":" & "C" & r
Range(myrange).Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.NumberFormat = "mm/dd/yy;@"
End With