2017-10-20 4 views
2

をセルデータを保存します - 私のExcelシート上エクセルVBA基本的に私はこのようなシートを持っている2.</p> <p>をワークシートに別のシートに、私はワークシート1からの私のセルのデータを保存する方法を

   | Job number | Job notes 

edit button | 345345  | just some text 

edit button | 345468  | more text 

edit button | 678934  | job info 

I各行に、コマンドボタンが押されたときにコマンドボタンを押してジョブ番号を検索し、テキストボックスデータを正しいジョブの行に保存する、各行にコマンドボタンがあります。私は編集中です。

コードは、ユーザーフォームを開くときに、テキストボックスにジョブの注意事項をロードするために

Private Sub savejobnotes_Click() 


Dim YourVariable As Variant 
Dim rowCount As Integer 
Dim rownum As String 
Set YourVariable = jobRef 


With ActiveSheet.Range("D:D") 
Set uRng = .Find(YourVariable, , xlValues, xlWhole, , MatchCase:=False, 
searchformat:=False) 
If Not uRng Is Nothing Then 
    uRng.Activate 
    rowCount = ActiveCell.Row 
    'this will find the row number rowCount 
    ' MsgBox rowCount 

    rownum = "K" & rowCount 
    MsgBox "Saved to " & rownum 

    'save textbox value to a cell 
    ActiveSheet.Range(rownum).Value = jobnotes.Value 


End If 
End With 
End Sub 

コードを保存します。

Sub loadjobnotes() 

Dim YourVariable As Variant 
Dim rowCount As Integer 
Dim rownum As String 
Set YourVariable = jobRef 
With ActiveSheet.Range("D:D") 
Set uRng = .Find(YourVariable, , xlValues, xlWhole, , MatchCase:=False, 
searchformat:=False) 
If Not uRng Is Nothing Then 
    uRng.Activate 
    rowCount = ActiveCell.Row 
    'this will find the row number rowCount 
    ' MsgBox rowCount 

    rownum = "K" & rowCount 
    ' MsgBox rownum 

jobnotes.Value = ActiveSheet.Range(rownum) 


    End If 
End With 
End Sub 

毎回、ジョブ番号とジョブノートを別のシートに保存しますか。私のExcelテーブルは.csvファイルから定期的に更新され、テーブルから完了したジョブを削除するので、ジョブ番号のコピーをジョブ番号にリンクしておく必要があります。

あなたが最初のジョブのような名前の新しいシートを作成し、このような構造を使用する必要があります任意の助け

答えて

0

てくれてありがとう:カウンターを作成する必要が

Sheets("Jobs").Cells("coordinates here").Value = "your values" 

たぶん、あなたがされるだろうが、それはですいくつかの他のトピック。

+0

私はその上に構築することができた情報をありがとう、今私はジョブ番号を検索し、それがexsistsかどうかをチェックし、新しいシートに追加したり、それを更新することができます。 – kiper3000

関連する問題