ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

MsgBox ªº°ÝÃD

¶}±Ò¥t¥~¤@­Ó¬¡­¶Ã¯

¥»©«³Ì«á¥Ñ jesscc ©ó 2011-5-7 12:31 ½s¿è

½Ð±Ð¦U¦ì¥ý¶i¤@­Ó°ÝÃD¡A§Ú­n¦bMain¬¡­¶Ã¯¤¤«ö"¶}Àɤñ¹ï"«ö¶s¶}±Ò¥t¥~¤@­Ó¬¡­¶Ã¯Matl Request *.xls(*¥Nªí¤£¦Pªº¤é´Á)

1.¦pªG"Matl Request *.xls"©|¥¼¶}±Ò¡A´N¦b "¶}±ÒÀÉ®×¹ï¸Ü®Ø" ¤¤±N¥¦¶}±Ò¡A¶¶«K§âÀɦW¶K¦bMain¬¡­¶Ã¯¤¤ªºRange("D1")¡A¥H«K«áÄòµ{¦¡¥Ñ¦¹¨ú±oÀɦW¡A¶i¦æ¬ÛÃö¤u§@(Workbooks(Workbooks("Main").Sheets("MRP").[D3].Text).Sheets("sheet1").Range("B11:N22").Copy Workbooks("Main").Sheets("MRP").Range("B11:N22"))¡C
2.¦pªG"Matl Request *.xls"¤w¶}±Ò¡A´N¤£¥ÎÅã¥Ü "¶}±ÒÀÉ®×¹ï¸Ü®Ø" ª½±µ§ì¨ú³o­ÓÀɦW¶K¦bMain¬¡­¶Ã¯¤¤ªºRange("D1")¡A¥H«K«áÄòµ{¦¡¥Ñ¦¹¨ú±oÀɦW¡A¶i¦æ¬ÛÃö¤u§@¡C

¥i¬O§Úªº¼gªk¦n¹³¨S¤°»ò§@¥Î¡A¤£ª¾¹D°ÝÃD¦b­þ¸Ì?¥i¥HÀ°§Ú¬Ý¬Ý¶Ü?ÁÂÁÂ!

test.rar (21.15 KB)
Jess

TOP

¦^´_ 1# jesscc
  1. Sub OpenFile1()
  2. FileToOpen = Application.GetOpenFilename _
  3. (Title:="¶}±Ò¥»¶g»Ý¨Dªí", _
  4. FileFilter:="Matl Request *.xls (*.xls),")
  5. If FileToOpen = False Then
  6. MsgBox "¥²¶·¶}±Ò »Ý¨Dªí¡A¤u§@¤~¯àÄ~Äò!", 48, "ÀÉ®×¥¼¶}±Ò"
  7. Exit Sub
  8. Else
  9. op = False
  10. fn = Split(FileToOpen, "\")(UBound(Split(FileToOpen, "\")))
  11. Var = MsgBox("½T©w¬O¶}±Ò³o¥÷»Ý¨Dªí¶Ü?", 36, "½Ð½T»{±ý¶}±Ò¤§ÀÉ®×")
  12. If Var = 6 Then
  13. For Each w In Windows 'ÀˬdÀɮ׬O§_¤w¶}±Ò
  14.    If w.Caption = fn Then op = True: Exit For
  15. Next
  16. If op = False Then Workbooks.Open Filename:=FileToOpen '¦pªGµøµ¡¤¤¨S¦³¶}±Ò»Ý¨Dªí´N¶}±Ò»Ý¨Dªí
  17. Set aw = Workbooks(fn) '±N»Ý¨Dªí³]µ¹ª«¥óÅܼƥH§Q«áÄò¨Ï¥Î
  18. Workbooks("Main.xls").Activate
  19. Sheets("MRP").Range("D1").Value = fn '±N»Ý¨DªíÀɦW¼g¤JÀx¦s®æ
  20. Else
  21. End If
  22. End If

  23. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-5-7 14:32 ½s¿è

¦^´_ 1# jesscc
¥i¬O§Úªº¼gªk¦n¹³¨S¤°»ò§@¥Î¡A¤£ª¾¹D°ÝÃD¦b­þ¸Ì?
Sub OpenFile1()
FileToOpen = Application.GetOpenFilename _
(Title:="¶}±Ò¥»¶g»Ý¨Dªí", _
FileFilter:="Matl Request *.xls (*.xls),")
If FileToOpen = False Then
MsgBox "¥²¶·¶}±Ò »Ý¨Dªí¡A¤u§@¤~¯àÄ~Äò!", 48, "ÀÉ®×¥¼¶}±Ò"
Exit Sub
Else
Var = MsgBox("½T©w¬O¶}±Ò³o¥÷»Ý¨Dªí¶Ü?", 36, "½Ð½T»{±ý¶}±Ò¤§ÀÉ®×")
'No  ->Var =7
'Yes->Var =6
If Var = 6 Then
Workbooks.Open Filename:=FileToOpen
Workbooks("Main.xls").Activate
Sheets("MRP").Range("D1").Value = FileToOpen
Else
End If
End If
End Sub

MsgBox «öÁä§PÂ_
  1. Sub Ex()
  2.     A = MsgBox("½T©w¬O¶}±Ò³o¥÷»Ý¨Dªí¶Ü?", vbYesNoCancel, "½Ð½T»{±ý¶}±Ò¤§ÀÉ®×")
  3.     If A = vbYes Then
  4.         MsgBox "¶}±ÒÀÉ®×"
  5.     ElseIf A = vbNo Then
  6.         MsgBox "¤£¶}±ÒÀÉ®×"
  7.     ElseIf A = vbCancel Then
  8.         MsgBox "¨ú®ø"
  9.     End If
  10. End Sub
½Æ»s¥N½X

TOP

­ì¨Ó³o»ò½ÆÂø¡A¥»¨ÓÁÙ¥H¬°¬O«Ü²³æªº°Ê§@©O?
·PÁÂ Hsieh ¤j!
¤£¹L­è­è´ú¸Õ¡AÁÙ¬O¦³¤@ÂI¤p°ÝÃD¡C¦pªG§Ú¤w¸g¥ý¥´¶}¤FMatl Request *.xls¡AµM«á¤~¦bMain¬¡­¶Ã¯¤¤«ö"¶}Àɤñ¹ï"«ö¶s¡Aµ²ªGÁÙ¬O·|¥X²{ "¶}±ÒÀÉ®×¹ï¸Ü®Ø" ¡A¦b³oºØ±¡§Î¤U¥i¥H²¤¹L"¶}±ÒÀÉ®×¹ï¸Ü®Ø"¡Aª½±µ¸õ¨ì§Úªº¤u§@¶Ü?
Jess

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2011-5-7 14:46 ½s¿è

¦^´_ 4# jesscc

¨º§A«ç»òÅýµ{¦¡ª¾¹D§A·Q¶}ªºÀɦW¬O¬Æ»ò?
¨Ò¦p¤w¦³2­Ó¤£¦P¤é´ÁªºÃþ¦üÀɦW¡A­n¥Î­þ¤@­Ó?
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ jesscc ©ó 2011-5-7 18:23 ½s¿è

»¡±o¤]¬O¡A§Ú¤£ª¾¤£Ä±´N§â¤Hªº«ä¦Ò±a¶i¹q¸£ùؤF¡C
Hsieh ¤j¤j¥i¥H¦AÀ°§Ú¬Ý¤@¤U¶Ü?
¦b³Ì«á¡A°}¦CÂಾ»Ý¨Dªí¸ê®Æªº¦a¤è¥X²{°»¿ù!¥i¤£¥i¥HÀ°§ÚÀˬd¤@¤U¬O­þ¸Ì¿ù¤F¶Ü?¬O¦]¬°°}¦CµLªkÂಾ»Ý¨Dªíùتº¤½¦¡¶Ü?
  1. Sub OpenFile1()
  2. FileToOpen = Application.GetOpenFilename _
  3. (Title:="¶}±Ò¥»¶g»Ý¨Dªí", _
  4. FileFilter:="Matl Request *.xls (*.xls),")
  5. If FileToOpen = False Then
  6. MsgBox "¥²¶·¶}±Ò »Ý¨Dªí¡A¤u§@¤~¯àÄ~Äò!", 48, "ÀÉ®×¥¼¶}±Ò"
  7. Exit Sub
  8. Else
  9. op = False
  10. fn = Split(FileToOpen, "\")(UBound(Split(FileToOpen, "\")))
  11. 'Var = MsgBox("½T©w¬O¶}±Ò³o¥÷»Ý¨Dªí¶Ü?", 36, "½Ð½T»{±ý¶}±Ò¤§ÀÉ®×")
  12. 'If Var = 6 Then
  13. For Each w In Windows 'ÀˬdÀɮ׬O§_¤w¶}±Ò
  14.    If w.Caption = fn Then op = True: Exit For
  15. Next
  16. If op = False Then Workbooks.Open FileName:=FileToOpen '¦pªGµøµ¡¤¤¨S¦³¶}±Ò»Ý¨Dªí´N¶}±Ò»Ý¨Dªí
  17. Set aw = Workbooks(fn) '±N»Ý¨Dªí³]µ¹ª«¥óÅܼƥH§Q«áÄò¨Ï¥Î
  18. Workbooks("Main.xls").Activate
  19. Sheets("MRP").Range("D1").Value = fn '±N»Ý¨DªíÀɦW¼g¤JÀx¦s®æ
  20. 'Else
  21. End If

  22. '°}¦CÂಾ»Ý¨Dªí¸ê®Æ
  23. Workbooks(fn).Activate
  24. Dim Ay()
  25. For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
  26. For j = 2 To 14
  27.           ReDim Preserve Ay(s)
  28.           Ay(s) = Array(Cells(i, j).Value)
  29.           s = s + 1
  30. Next j
  31. Next i
  32. Workbooks("Main.xls").Activate
  33. With Sheets("MRP")
  34.     Cells(4, 14).NumberFormat = "dd/mm/yyyy"
  35.     Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Resize(s, 13) = Application.Transpose(Application.Transpose(Ay))
  36. End With
  37. End sub
½Æ»s¥N½X
Jess

TOP

aw.Sheets("sheet1").[B11:N22].Copy Workbooks("Main").Sheets("MRP").[B11:N22]
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

MsgBox ªº°ÝÃD

¥»©«³Ì«á¥Ñ jesscc ©ó 2011-5-13 00:48 ½s¿è

¥H¤U¥N½X¡A·Q°µªº°Ê§@¬O:
«ö"½T©w"·|§R°£Range("B7:J1000")ªº¸ê®Æ¡A«ö¤U"¨ú®ø"´N°h¥Xµ{¦¡¡A¤£°µ°Ê§@¡C
¥i¬O¤£ºÞ§Ú«ö­þ¤@­Ó³£¨S¦³§@¥Î¡A¬O­þ¸Ì¦³¿ù¶Ü?
  1. Sub Macro1()
  2. MsgBox "³o¼Ë°µ·|²M°£ NEW ¤u§@­¶ªº¸ê®Æ!" & vbCrLf & vbCrLf & "§A½T©w­n³o¼Ë°µ¶Ü?", vbOKCancel + vbQuestion, "²M°£ NEW ­ì©l¸ê®Æ!"
  3. If Var = 1 Then
  4. Worksheets("NEW").Range("B7:J1000").ClearContents
  5. End If
  6. If Var = 2 Then
  7. Exit Sub
  8. End If
  9. End Sub
½Æ»s¥N½X
1

µû¤À¤H¼Æ

    • GBKEE: °ÝÃD¤w´£°Ý¹L ¤£¥Î¤ß 2,3¼Ó¦^ÂФFª÷¿ú -2
Jess

        ÀR«ä¦Û¦b : ¦³´¼¼z¤~¯à¤À¿ëµ½´c¨¸¥¿¡F¦³Á¾µê¤~¯à«Ø¥ß¬üº¡¤H¥Í¡C
ªð¦^¦Cªí ¤W¤@¥DÃD