Ask Cần tìm người giúp viết Macro export dữ liệu từ Excel qua Powerpoint

### Cách xuất dữ liệu từ excel sang powerpoint với macro

**Tổng quan**

Bài viết này sẽ chỉ cho bạn cách xuất dữ liệu từ Excel sang PowerPoint bằng macro.Macro là những chương trình nhỏ có thể được sử dụng để tự động hóa các tác vụ trong Excel.Bằng cách sử dụng macro, bạn có thể dễ dàng xuất dữ liệu từ Excel sang PowerPoint mà không cần phải sao chép thủ công và dán dữ liệu.

** Điều kiện tiên quyết **

Để làm theo hướng dẫn này, bạn sẽ cần những điều sau đây:

* Microsoft Excel
* Microsoft Powerpoint
* Trình chỉnh sửa VBA (Visual Basic cho các ứng dụng)

** Bước 1: Tạo một macro trong Excel **

Bước đầu tiên là tạo một macro trong Excel sẽ xuất dữ liệu sang PowerPoint.Để làm điều này, hãy làm theo các bước sau:

1. Mở sổ làm việc Excel có chứa dữ liệu bạn muốn xuất.
2. Nhấp vào tab ** Nhà phát triển ** trên ruy băng.
3. Trong nhóm ** mã **, nhấp vào ** Visual Basic **.
4. Trình soạn thảo ** Visual Basic ** sẽ mở.
5. Trong cửa sổ ** Project Explorer **, nhấp chuột phải vào ** VBProject ** nút và chọn ** Chèn **> ** Mô-đun **.
6. Một mô -đun mới sẽ được tạo.
7. Trong cửa sổ ** mô -đun **, nhập mã sau:

`` `
Sub ExportDatatopowerPoint ()

'Khai báo các biến.
Dim wbexcel như sổ làm việc
Dim WBPowerPoint như sổ làm việc
Dim Shtexcel làm bảng tính
Dim ShtPowerPoint làm bảng tính
Dimer rngdata là phạm vi
Dim strfilename dưới dạng chuỗi

'Nhận các đối tượng sổ làm việc và bảng tính.
wbexcel = ActiveWorkbook
shtexcel = tờ ("sheet1")

'Nhận phạm vi dữ liệu.
rngdata = shtexcel.range ("a1: d10")

'Tạo sổ làm việc PowerPoint.
WBPowerPoint = New Workbook

'Tạo một bảng tính mới trong sổ làm việc PowerPoint.
ShtPowerPoint = WBPowerPoint.WorkSheet.Add ()

'Sao chép dữ liệu từ Excel sang PowerPoint.
ShtPowerPoint.range ("A1").

'Lưu sổ làm việc PowerPoint.
wbpowerpoint.saveas fileName: = strfilename, fileformat: = xlPowerPointpresentation

'Đóng sổ làm việc PowerPoint.
wbpowerpoint.close

Kết thúc phụ
`` `

** Bước 2: Chạy macro **

Khi bạn đã tạo macro, bạn có thể chạy nó để xuất dữ liệu sang PowerPoint.Để làm điều này, hãy làm theo các bước sau:

1. Trong ** Trình chỉnh sửa cơ bản **, nhấp vào nút ** chạy **.
2. Macro sẽ chạy và dữ liệu sẽ được xuất sang bản trình bày PowerPoint mới.

** Bước 3: Xem dữ liệu trong PowerPoint **

Để xem dữ liệu trong PowerPoint, hãy mở trình bày PowerPoint được tạo bởi Macro.Dữ liệu sẽ nằm trong bảng tính đầu tiên của bài thuyết trình.

### Lời khuyên

* Bạn có thể sử dụng các chức năng VBA sau đây để lấy dữ liệu từ Excel:
*** activesheet.range ("A1: d10"). Giá trị ** - Điều này sẽ nhận được các giá trị từ phạm vi A1: D10.
*** activesheet.range ("A1: d10"). Text ** - Điều này sẽ lấy văn bản từ phạm vi A1: D10.
*** activesheet.range ("A1: D10"). Công thức ** - Điều này sẽ nhận được các công thức từ phạm vi A1: D10.
* Bạn có thể sử dụng các chức năng VBA sau đây để đặt dữ liệu trong PowerPoint:
*** Phạm vi ("A1"). Value = "Data" ** - Điều này sẽ đặt giá trị của ô A1 thành "Dữ liệu".
*** Phạm vi ("A1"). Text = "Data" ** - Điều này sẽ đặt văn bản của ô A1 thành "Dữ liệu".
*** Phạm vi ("A1"). Công thức = "= sum (A2: A10)" ** - Điều này sẽ đặt công thức của ô A1 thành "= sum (A2: A10)".
* Bạn có thể sử dụng các chức năng VBA sau để lưu
=======================================
### How to Export Data from Excel to PowerPoint with Macros

**Overview**

This article will show you how to export data from Excel to PowerPoint using macros. Macros are small programs that can be used to automate tasks in Excel. By using a macro, you can easily export data from Excel to PowerPoint without having to manually copy and paste the data.

**Prerequisites**

To follow this tutorial, you will need the following:

* Microsoft Excel
* Microsoft PowerPoint
* The VBA Editor (Visual Basic for Applications)

**Step 1: Create a Macro in Excel**

The first step is to create a macro in Excel that will export the data to PowerPoint. To do this, follow these steps:

1. Open the Excel workbook that contains the data you want to export.
2. Click the **Developer** tab on the ribbon.
3. In the **Code** group, click **Visual Basic**.
4. The **Visual Basic Editor** will open.
5. In the **Project Explorer** window, right-click the **VBProject** node and select **Insert** > **Module**.
6. A new module will be created.
7. In the **Module** window, type the following code:

```
Sub ExportDataToPowerPoint()

' Declare variables.
Dim wbExcel As Workbook
Dim wbPowerPoint As Workbook
Dim shtExcel As Worksheet
Dim shtPowerPoint As Worksheet
Dim rngData As Range
Dim strFileName As String

' Get the workbook and worksheet objects.
wbExcel = ActiveWorkbook
shtExcel = Sheets("Sheet1")

' Get the data range.
rngData = shtExcel.Range("A1:D10")

' Create the PowerPoint workbook.
wbPowerPoint = New Workbook

' Create a new worksheet in the PowerPoint workbook.
shtPowerPoint = wbPowerPoint.Worksheets.Add()

' Copy the data from Excel to PowerPoint.
shtPowerPoint.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

' Save the PowerPoint workbook.
wbPowerPoint.SaveAs Filename:=strFileName, FileFormat:=xlPowerPointPresentation

' Close the PowerPoint workbook.
wbPowerPoint.Close

End Sub
```

**Step 2: Run the Macro**

Once you have created the macro, you can run it to export the data to PowerPoint. To do this, follow these steps:

1. In the **Visual Basic Editor**, click the **Run** button.
2. The macro will run and the data will be exported to a new PowerPoint presentation.

**Step 3: View the Data in PowerPoint**

To view the data in PowerPoint, open the PowerPoint presentation that was created by the macro. The data will be in the first worksheet of the presentation.

### Tips

* You can use the following VBA functions to get the data from Excel:
* **ActiveSheet.Range("A1:D10").Value** - This will get the values from the range A1:D10.
* **ActiveSheet.Range("A1:D10").Text** - This will get the text from the range A1:D10.
* **ActiveSheet.Range("A1:D10").Formula** - This will get the formulas from the range A1:D10.
* You can use the following VBA functions to set the data in PowerPoint:
* **Range("A1").Value = "Data"** - This will set the value of cell A1 to "Data".
* **Range("A1").Text = "Data"** - This will set the text of cell A1 to "Data".
* **Range("A1").Formula = "=SUM(A2:A10)"** - This will set the formula of cell A1 to "=SUM(A2:A10)".
* You can use the following VBA functions to save
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock