Cyberdude
12-14-2006, 01:14 PM
I have a macro that creates a small table of data:
.......Col ?A? ............Col ?B?...Col ?C? .Col ?D?....Col ?E?.... Col ?F?
|Willing to Spend | Cost per | Estim |...........| Diff From | Estim |
|......$70,000...... |...Share .|$ Cost |(empty)| $70,000.| Shares |
...................+3% ...$14.80 .$69,565 .............. -$435 .....4700
.................. +2% ...$14.66 .$70,356 ..............+$356 .....4800
.................. +1% ...$14.51..$69,666 ...............-$334 .....4800
. . .
The values in column ?C? are too wide, so I want to either:
A. merge columns ?C? and ?D?, -OR-
B. use .HorizontalAlignment = xlCenterAcrossSelection to give the appearance that column ?C? headers and data are occupying both columns ?C? and ?D?.
When I use the statement:
Range(ColC & SelRow & ":" & ColD & SelRow).Merge (True)
it works, except when it applies to the two header values in column ?C? I get the message:
?The selection contains multiple data values. Merging into one cell will keep the
upper-leftmost data only.?
I reply ?OK? and it proceeds normally. This message does not occur for the data lines, just the headers. I?ve tried to determine what the multiple values are, and I?ve tried to delete all values (if any) in column ?D?. Column ?D? doesn?t seem to have any values. I?ve tried placing the outut is several places on the sheet, and I still get the two messages.
I tried using On Error Resume Next to prevent the merge message from occurring, but I suppose an actual error doesn?t occur, so that was no help.
Next I tried to use .HorizontalAlignment = xlCenterAcrossSelection after selecting the cells in column ?C? and ?D?. I didn?t get a message, but the alignment just worked on column ?C?, i.e., it didn?t spread any of the values across column ?C? and ?D?.
Suggestions anyone?
.......Col ?A? ............Col ?B?...Col ?C? .Col ?D?....Col ?E?.... Col ?F?
|Willing to Spend | Cost per | Estim |...........| Diff From | Estim |
|......$70,000...... |...Share .|$ Cost |(empty)| $70,000.| Shares |
...................+3% ...$14.80 .$69,565 .............. -$435 .....4700
.................. +2% ...$14.66 .$70,356 ..............+$356 .....4800
.................. +1% ...$14.51..$69,666 ...............-$334 .....4800
. . .
The values in column ?C? are too wide, so I want to either:
A. merge columns ?C? and ?D?, -OR-
B. use .HorizontalAlignment = xlCenterAcrossSelection to give the appearance that column ?C? headers and data are occupying both columns ?C? and ?D?.
When I use the statement:
Range(ColC & SelRow & ":" & ColD & SelRow).Merge (True)
it works, except when it applies to the two header values in column ?C? I get the message:
?The selection contains multiple data values. Merging into one cell will keep the
upper-leftmost data only.?
I reply ?OK? and it proceeds normally. This message does not occur for the data lines, just the headers. I?ve tried to determine what the multiple values are, and I?ve tried to delete all values (if any) in column ?D?. Column ?D? doesn?t seem to have any values. I?ve tried placing the outut is several places on the sheet, and I still get the two messages.
I tried using On Error Resume Next to prevent the merge message from occurring, but I suppose an actual error doesn?t occur, so that was no help.
Next I tried to use .HorizontalAlignment = xlCenterAcrossSelection after selecting the cells in column ?C? and ?D?. I didn?t get a message, but the alignment just worked on column ?C?, i.e., it didn?t spread any of the values across column ?C? and ?D?.
Suggestions anyone?