[英]Find a specific value in 2nd Column and distinct all its 1st column using excel
[英]Excel Rows (1st column) as .php files + Excel Row 1 (2nd column to infinty) as data of all files
我找到了相關的東西,但沒有找到完全匹配的東西,我也不知道如何解決。
我有一個只有1行(多列)和1列(多行)的excel文件。
現在,我想使用vba並從第1列的所有行創建文件,然后在所有文件中放入相同的數據(即cloumn b表示第1行的無窮大)。
只是一個例子:
Excel文件:
a 2 3 4
b
c
文件將是:
a.php, b.php, c.php
其中包含相同的數據:
2 3 4
提前致謝
盡管這樣做的基本原理使我難以理解,但這是微不足道的。 只需遍歷第一行以獲取數據,然后遍歷第一列以獲取文件名和輸出副本:
Const path = "C:\YourDestinationDirectory\"
Public Sub DumpPHP()
Dim sheet As Worksheet
Dim data As String
Dim index As Long
Set sheet = ActiveSheet
For index = 2 To sheet.UsedRange.Columns.Count
data = data & sheet.Cells(1, index)
Next index
Dim handle As Integer
For index = 2 To sheet.UsedRange.Rows.Count
handle = FreeFile
Open path & sheet.Cells(index, 1) & ".php" For Output As #handle
Print #handle, data
Close #handle
Next index
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.