返回列表 上一主題 發帖

一個複雜的表單問題

回復 20# Hsieh
謝謝hsieh版大悉心教導, 大大用的排序是03版, 請問07版中如何運用, 因應07排序與03似有區別, 謝謝!!

TOP

回復 21# 周大偉
  1. Private Sub Label1_Click() '新增資料

  2. Dim Ar(), A As Range, B As Range, C As Range, MyPic As Shape
  3. Set dpic = CreateObject("Scripting.Dictionary")

  4. Set C = Sheet1.[A:A].Find(TextBox1.Text, lookat:=xlWhole)

  5. If Not C Is Nothing Then MsgBox ("學號重複,請重新檢查"): Exit Sub

  6. fd = ThisWorkbook.Path & "\"

  7. If Dir(fd & "Temp.bmp") <> "" Then Kill fd & "Temp.bmp"

  8. SavePicture Image1.Picture, fd & "Temp.bmp"

  9. obs = Array("TextBox1", "TextBox2", "TextBox3", "TextBox4", "TextBox5", "TextBox6", "ComboBox1", "TextBox7", "TextBox8", "TextBox9", "TextBox10", "TextBox11", "ComboBox2")


  10. For i = 0 To 12

  11.      ReDim Preserve Ar(i)

  12.      Ar(i) = Controls(obs(i)).Text

  13. Next

  14. With Sheet1

  15.    Set A = .Cells(.Rows.Count, 1).End(xlUp).Offset(1)

  16.    A.RowHeight = 79.8

  17.    Set B = A.Offset(, 13)

  18.    A.Resize(, 13) = Ar

  19.    Set MyPic = .Shapes.AddPicture(fd & "Temp.bmp", msoFalse, msoCTrue, B.Left, B.Top, B.Width, B.Height)

  20.    For Each pic In Sheet1.Shapes
  21.       If pic.Type = 13 Then dpic(.Cells(pic.TopLeftCell.Row, 1).Value) = pic.Name
  22.    Next

  23.    .Range("A3").CurrentRegion.Sort key1:=.[A4], Header:=xlYes  '排序
  24.    If Val(Application.Version) > 11 Then
  25.       For Each A In .Range(.[A4], .Cells(.Rows.Count, 1).End(xlUp))
  26.           .Shapes(dpic(A.Value)).Top = A.Top
  27.       Next
  28.     End If

  29. End With

  30. Unload Me: UserForm1.Show

  31. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 22# Hsieh

hsieh版大, 早晨
謝謝大大的修改, 圖片亦能排序, 真的很感動版大幫忙, 再一次衷心怠謝謝, 祝願健康, 快樂..

TOP

        靜思自在 : 人要知福、惜福、再造福。
返回列表 上一主題