更新时间:2022-10-31 08:22:48
我相信这是你正在寻找的:
Dim intPointer as Integer
Dim strFileToImport as String
Dim strLine as String
intPointer = FreeFile()
打开strFileToImport对于输入访问读取锁读为#intPointer
直到EOF(intPointer)
行输入#intPointer,strLine
SheetWithLocations.Cells(lngRow,1).Value2 = strLine
lngRow = lngRow + 1
循环
它打开一个名为strFileToImport的外部txt文件,并从txt文件逐行读取并将其写入SheetWithLocations。 / p>
I have an excel sheet that has two sheets. One sheet is hidden that has a list of values called "Location." On the main sheet I have created a drop down menu that pulls from the hidden sheet.
How can I store these values in an external file (Excel, .txt, etc.) so I can hit a macro button (VBA) that will replace/update the list on the hidden sheet with any/all new Location values that will be stored in an external file?
I believe this is what you are looking for:
Dim intPointer as Integer
Dim strFileToImport as String
Dim strLine as String
intPointer = FreeFile()
Open strFileToImport For Input Access Read Lock Read As #intPointer
Do Until EOF(intPointer)
Line Input #intPointer, strLine
SheetWithLocations.Cells(lngRow, 1).Value2 = strLine
lngRow = lngRow + 1
Loop
It opens an external txt file called strFileToImport and reads row by row from the txt file and writes it into the SheetWithLocations.