![]() |
||
Regular Member
![]() ![]() 加入日期: Jan 2002
文章: 64
|
![]() ![]() A欄是抓取住家電話或手機末5碼作為編號, 寫入公式 =IF(ISBLANK(資料!C3),IF(ISBLANK(資料!D3),"",RIGHT((資料!D3),5)),RIGHT((資料!C3),5)) 想改寫成VBA, 無奈對VBA一竅不通。上來請教各位 ~~~~萬分感謝~~~ |
|||||||
![]() |
![]() |
*停權中*
加入日期: Feb 2004
文章: 2,909
|
FOR I = 1 to 100
編號= CELLS(I,3) IF 編號="" THEN 編號= CELLS(I,4) END IF CELLS(I,1)= RIGHT(編號,5) NEXT I ================================= 大概隨便寫一下 可能有錯誤 差不多就樣吧= =a |
||
![]() |
![]() |
Regular Member
![]() ![]() 加入日期: Aug 2005
文章: 72
|
公式可以解決的問題,應該使用公式。
VBA沒有比較聰明。 Sub xxx() Set currgn = ActiveCell.CurrentRegion Set c = currgn.Find("*姓*名*") If Not c Is Nothing Then Range(c.Address).Offset(1, 0).Select Else Exit Sub End If While ActiveCell.Value <> "" If ActiveCell.Offset(0, 1).Value <> "" Then ActiveCell.Offset(0, -1).Value = Right(ActiveCell.Offset(0, 1).Value, 5) End If If ActiveCell.Offset(0, 2).Value <> "" Then ActiveCell.Offset(0, -1).Value = Right(ActiveCell.Offset(0, 2).Value, 5) End If ActiveCell.Offset(1, 0).Select Wend End Sub 此文章於 2012-11-03 02:47 PM 被 ccx1103 編輯. |
![]() |
![]() |