麻辣家族討論版版's Archiver

dodocho 發表於 2011-4-28 23:35

儲存格合併

各位大大好:
我想請問在EXCEL裡面
有什麼方法可以讓儲存格合併時
2個儲存格的資料都在
因為正常情況下儲存格合併時
只會留下前面哪一格的資料
另一格資料會不見??
麻煩一下    謝謝

Hsieh 發表於 2011-4-29 00:06

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=18936&ptid=3382]1#[/url] [i]dodocho[/i] [/b]


    [attach]5903[/attach]

dodocho 發表於 2011-4-29 00:34

大大對不起
我沒講清楚
我希望A1儲存格裡面1
        A2儲存格裡面2
A1A2合併成一個儲存格時
裡面顯示12
舉個例A1儲存格裡面   "生日"
        A2儲存格裡面2  "快樂"
合併後變成.生日快樂而不是只出現生日

ANGELA 發表於 2011-4-29 08:37

合併格只能顯示第一個儲存格的資料.第二個儲存格的資料可保存不能顯示.

mark15jill 發表於 2011-4-29 10:26

[i=s] 本帖最後由 mark15jill 於 2011-4-29 10:32 編輯 [/i]

因不曉得說樓主是要大量還是單筆 所以 做了一筆的資料
看樓主是要哪種格式
使用方法 巨集快捷預設 ctrl + e 請自行修改

1.在A1 B1 輸入想要的字後 顯示在 A1B1..
2.在C1 D1 輸入想要的值後 顯示在 C1..
如果要多筆的話  程式碼可能還得修改..


[attach]5906[/attach]

oobird 發表於 2011-4-29 11:00

操作中遇到內建功能無提供的作業
常會須要用到程式碼輔助
[attach]5907[/attach]

dodocho 發表於 2011-4-29 22:13

mark15jill 大大你好
對不起,本人用的是2003版本
所以無法開啟
請問可以給我程式碼嗎??
謝謝

ann 發表於 2011-5-2 16:28

[quote]操作中遇到內建功能無提供的作業
常會須要用到程式碼輔助
[size=2][color=#999999]oobird 發表於 2011-4-29 11:00[/color] [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=18959&ptid=3382][img]http://forum.twbts.com/images/common/back.gif[/img][/url][/size][/quote]


  不知超級版主-合併儲存格且保留所有儲存格內容的功能如何做到?
  可以分享程式碼嗎?

mark15jill 發表於 2011-5-2 17:25

[i=s] 本帖最後由 mark15jill 於 2011-5-2 17:29 編輯 [/i]

[quote]mark15jill 大大你好
對不起,本人用的是2003版本
所以無法開啟
請問可以給我程式碼嗎??
謝謝
[size=2][color=#999999]dodocho 發表於 2011-4-29 22:13[/color] [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=18990&ptid=3382][img]http://forum.twbts.com/images/common/back.gif[/img][/url][/size][/quote]

抱歉 沒注意到這帖的訊息.....
用2007用習慣 常常會忘記要轉成其他版本格式..

程式碼如下(另有附帶檔案 2003格式的)  
如有問題 再回復文章...

Sub Macro1()
'
' Macro1 Macro
'
' 快速鍵: Ctrl+e

    Range("A3:b3").Select
    ActiveCell.FormulaR1C1 = Range("A1") & Range("B1")
   
    Range("A2:B2").Select '選擇 A2到B2 儲存格
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Merge
    Range("A2").Select
    ActiveCell.FormulaR1C1 = Range("A3")
   
    Range("A3").Select
    ActiveCell.FormulaR1C1 = ""



    Range("C1:D1").Select

    Range("C2").Select
    ActiveCell.FormulaR1C1 = Range("C1") & Range("D1")


End Sub




[attach]5943[/attach]

Hsieh 發表於 2011-5-2 19:33

[b]回復 [url=http://forum.twbts.com/redirect.php?goto=findpost&pid=19125&ptid=3382]8#[/url] [i]ann[/i] [/b]


    要第一個儲存格顯示所有值,第2個儲存格以後的值保留?
[attach]5944[/attach][code]Private Sub CommandButton1_Click() '合併
Dim ar()
Application.ScreenUpdating = False
With Selection
adr = .Address
For Each a In .Cells
ReDim Preserve ar(s)
ar(s) = a
s = s + 1
Next
.ClearContents
For Each a In .Cells
a.Value = ar(i)
i = i + 1
Next
.Cells(1, 1).Value = Join(ar)
With Sheets.Add
Set ns = ActiveSheet
.Range(adr).Merge
.Range(adr).Copy
End With
.PasteSpecial Paste:=xlPasteFormats
Application.DisplayAlerts = False
ns.Delete
Application.DisplayAlerts = True
End With
Application.ScreenUpdating = True
End Sub

Private Sub CommandButton2_Click() '分解
With Selection
r = 1
mystr = .Cells(1)
.UnMerge
.Cells(1) = Split(mystr, " ")(0)
End With
End Sub
[/code]

頁: [1]

麻辣家族討論版版為 麻辣學園 網站成員  由 昱得資訊工作室 © Since 1993 所提供