image 2Sometimes we want to use one sheet of the excel as a form that is used to get the inputs from the user. the data entered by the user, we try to save it on some other sheets that may notbe accessible to the end user for the security of the data of course. In this article, we will learn how to how we can update data from one sheet to another using VBA.

それで、私の退屈な話にこれ以上踏み込むことなく、概念を理解するために例を掘り下げてみましょう。

例:Sheet1に入力された値に基づいてSheet2のデータを更新するコールセンターで働いている従業員のためにこのコードを記述します。クライアントがそれらを呼び出すとき、User_Name、User_ID、Phone_Number、Problem_IDなどの基本的な詳細を取得します。

ここで、電話がかかってきたときに上記のすべての詳細をExcelシートに書き留め、[更新]をクリックすると、そのデータを別のシートで更新する必要があるマクロを記述します。

image 1

あるシートから別のシートにデータを更新するには、以下の手順に従います。-•最初に、ワークシートにコマンドボタンを挿入します。

•[開発者]タブに移動し、Activexcontrolからコマンドボタンを挿入します。

•下記のマクロを割り当てます:-

Private Sub CommandButton1_Click()

Dim User_Name As String, User_ID As Integer, Phone_Number As Double, Problem_ID As Integer

Worksheets("Sheet1").Select

User_Name = Range("B2")

User_ID = Range("B3")

Phone_Number = Range("B4")

Problem_ID = Range("B5")

Worksheets("Sheet2").Select

Worksheets("Sheet2").Range("A1").Select

If Worksheets("Sheet2").Range("A1").Offset(1, 0) <> "" Then

Worksheets("Sheet2").Range("A1").End(xlDown).Select

End If

ActiveCell.Offset(1, 0).Select

ActiveCell.Value = User_Name

ActiveCell.Offset(0, 1).Select

ActiveCell.Value = User_ID

ActiveCell.Offset(0, 1).Select

ActiveCell.Value = Phone_Number

ActiveCell.Offset(0, 1).Select

ActiveCell.Value = Problem_ID

Worksheets("Sheet1").Select

Worksheets("Sheet1").Range("B2").Select

End Sub

コードの説明:-最初に、すべての変数を定義しました。次に、すべての変数の範囲を定義し、次にすべての変数の範囲を記述しました。そして、[更新]ボタンをクリックした後、どこでどの範囲のデータが更新されるかを定義しました。

image 2

•コードを実行するには、キーボードのキーF5を押します。

•データを入力して更新ボタンをクリックすると、データは別のシートで更新され、シートに新しいデータを入力できます。

image 3

image 4

このようにして、MicrosoftExcelのVBAを介して1つのシートから別のシートにデータを更新できます。私は十分に説明できたと思います。この記事または他のExcelVBA記事について疑問がある場合は、以下のコメントセクションで質問してください。

image 48

関連記事

link:/ applications-word-outlook-in-vba-getting-started-with-excel-vba-userforms [ExcelVBAユーザーフォーム入門] | * Excelユーザーフォームは、ユーザーから情報を取得するのに役立ちます。 VBAユーザーフォームから始める方法は次のとおりです

===

`link:/ user-forms-input-boxes-in-vba-change-the-valuecontent-of-several-userform-controls-using-vba-in-microsoft-excel [いくつかのUserForm-controlsの値/コンテンツを変更しますExcelでVBAを使用する] `| *ユーザーフォームコントロールのコンテンツを変更するには、この単純なVBAスニペットを使用します。

`link:/ user-forms-input-boxes-in-vba-prevent-a-userform-from-closeing-when-the-user-clicks-the-x-button-using-vba-in-microsoft-excel [ ExcelでVBAを使用して、ユーザーがxボタンをクリックしたときにユーザーフォームが閉じないようにします] `|ユーザーがフォームのxボタンをクリックしたときにユーザーフォームが閉じないようにするために、UserForm_QueryCloseイベントを使用します。

人気の記事:

link:/ keyboard-formula-shortcuts-50-excel-shortcuts-to-increase-your-productivity [生産性を高めるための50のExcelショートカット] |あなたの仕事をより速くしてください。これらの50のショートカットにより、Excelでの作業がさらに高速になります。

link:/ forms-and-functions-introduction-of-vlookup-function [ExcelのVLOOKUP関数] |これは、さまざまな範囲やシートから値を検索するために使用される、Excelの最も使用され人気のある関数の1つです。

link:/ Tips-countif-in-microsoft-excel [COUNTIF in Excel 2016] |この驚くべき関数を使用して、条件付きの値をカウントします。特定の値をカウントするためにデータをフィルタリングする必要はありません。

ダッシュボードを準備するには、Countif関数が不可欠です。

link:/ excel-formula-and-function-excel-sumif-function [ExcelでSUMIF関数を使用する方法] |これは、ダッシュボードのもう1つの重要な機能です。これは、特定の条件で値を合計するのに役立ちます。