返回列表 上一主題 發帖

4個VBA問題

回復 10# kimbal
RUN時有問題
A1=10  E1="">RUN 2次>  C1出1(正常C1會出2 )
18-21.那裡是要   IF  ES<>"" AND V=ES  THEN....>RUN >C1=e
可以加多個g1   if  g1=1 就把 所有save的東西del. 還有,如果我這個excel有問題,可以把save的東西copy到第2個excel嗎?
50 字節以內
不支持自定義 Discuz! 代碼

TOP

回復 11# basarasy
有關c1問題, 之次錯刪了一下,可以再試試這個
  1.     On Error Resume Next
  2.     Dim currRow As Long
  3.     Dim es As String
  4.     Dim e As Integer
  5.     Dim nextvalue As Integer
  6.     Dim sheetname As String
  7.    
  8.     sheetname = Worksheets("entries").Name
  9.    
  10.     If sheetname = "" Then
  11.         MsgBox ("Sheet ""entries"" not found!")
  12.         Exit Sub
  13.     End If
  14.     currRow = 0
  15.    
  16.     v = Range("A1")
  17.    
  18.     es = Range("E1").Value
  19.     e = Range("F1").Value
  20.     If es <> "" Then
  21.         v = es
  22.     Else
  23.         e = 0
  24.     End If
  25.    
  26.     currRow = WorksheetFunction.Match(v, Worksheets(sheetname).Range("A:A"), False)
  27.     With Worksheets(sheetname)
  28.         If currRow = 0 Then
  29.             currRow = .Range("A65536").End(xlUp).Row + 1
  30.             .Range("A1").Offset(currRow - 1) = v
  31.             nextvalue = 1
  32.         Else
  33.             nextvalue = .Range("A1").Offset(currRow - 1, 1) + 1
  34.         End If
  35.         If e > 0 Then
  36.             nextvalue = e
  37.         End If
  38.         .Range("A1").Offset(currRow - 1, 1) = nextvalue
  39.     End With
  40.    
  41.     If currRow > 0 Then
  42.         Range("C1").Value = nextvalue
  43.     End If
複製代碼
這個或者你試試自己動手吧,
"可以加多個g1   if  g1=1 就把 所有save的東西del"
save的代碼是
thisworkbook.save

"還有,如果我這個excel有問題,"
可以,vba內容跟沒有跟workbook定位.... 你也試試了解一下中關運作吧~有行數不明白可以問一下的.
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

本帖最後由 basarasy 於 2010-7-25 17:05 編輯

回復 12# kimbal

大多都明白了.謝謝大大
只要把entries   del就可以 初期化了.

e1  and  f1  有問題
我入e1同f1 其實是  當我a1=10時 不小心按了2下run  c1出了2  之後入e1=10 f1=1 >run  c1就會
變回1.  不用把e1同f1 save在entries,只要改entries內 對照的b:b 就ok了.

不save是否改
If es = "" Then
            .Range("A1").Offset(currRow - 1) = v
            End If

If es = "" Then        
        .Range("A1").Offset(currRow - 1, 1) = nextvalue
        End If  這個?

但改entries內 對照的b:b不知改那裡.
50 字節以內
不支持自定義 Discuz! 代碼

TOP

如果我要把entries的東西save在 其他excel要如果寫?
50 字節以內
不支持自定義 Discuz! 代碼

TOP

回復 13# basarasy


有關 "e1  and  f1  有問題"
可以把
    Dim es As String
的 as string 拿走就可以了

"如果我要把entries的東西save在 其他excel要如果寫?"
學習巨集基本法: 錄製巨集

在excel上
1. 開發人員->錄製巨集, 按確定
2. 常用->儲存格->格式->移動或複製工作表, 選位置
3. 開發人員->停止錄製
到vbe查看巨集
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

回復 15# kimbal


    謝謝大大^^
50 字節以內
不支持自定義 Discuz! 代碼

TOP

        靜思自在 : 【時間成就一切】時間可以造就人格,可以成就事業,也可以儲積功德。
返回列表 上一主題