Ausschneiden und Einfügen in Excel-Makro

854
nvdkgm

Ich habe ungefähr 9.000 Spalten (geht zu Spalte MGN), die 14 Zeilen mit Datenpunkten haben. Ich muss die Daten in einer einzelnen Spalte mit dem Format Spalte B unter A, C unter B usw. abrufen.

Gibt es ein Makro oder eine Aufgabe, die ich ausführen kann, damit es auf einmal ausgeführt werden kann? Jede Hilfe wäre dankbar.

0

1 Antwort auf die Frage

1
STTR

If I understand correctly, then you get a result of 126 000 lines, or slightly more than 2,500 pages of A4 ... If you need to analyze it in person, the idea of ​​a single column is not very good.

ex:

xls2col2.vbs Book 1.xlsx 

Or drag&drop excel file to vbscript:

drag&drop excel file to vbscript

use Book 1.txt

xls2col2.vbs:

If WScript.Arguments.Count <1 then Wscript.Echo "Ex.1: cscript xls2col.vbs filename.xls" Wscript.Echo "Ex.2: cscript xls2col.vbs filename.xlsx" Wscript.Quit End If Const OpenAsDefault = -2 Const FailIfNotExist = 0 Const ForReading = 1 Const ForWriting = 2 Const xlTextWindows=20 Const xlUnicodeText=42 Const ExtName = ".txt" Dim ConvertExt:ConvertExt = xlTextWindows Dim strFilePath:strFilePath = WScript.Arguments.Item(0) Dim FSO:Set FSO = CreateObject("Scripting.FileSystemObject") If FSO.FileExists(strFilePath) Then Dim FileProperties:Set FileProperties=FSO.GetFile(strFilePath) Dim strOpenFileName : strOpenFileName = FileProperties.Path Dim FileConvertName : FileConvertName = FSO.BuildPath(FileProperties.ParentFolder, FSO.GetBaseName(FileProperties) & ExtName) Dim ExcelApplication:Set ExcelApplication = CreateObject("Excel.Application") ExcelApplication.Workbooks.Open(strOpenFileName) ExcelApplication.DisplayAlerts = FALSE ExcelApplication.Visible = FALSE ExcelApplication.Workbooks(1).SaveAs FileConvertName, ConvertExt ExcelApplication.Quit WScript.Sleep 5000 Set FSO = CreateObject("Scripting.FileSystemObject") Dim file: Set file = FSO.OpenTextFile(FileConvertName, ForReading, FailIfNotExist, OpenAsDefault) Dim FileReadAll: FileReadAll = file.ReadAll file.Close FileReadAll = Replace(FileReadAll, Chr(9), Chr(13)&Chr(10)) Set file = FSO.OpenTextFile(FileConvertName, ForWriting, True) file.Write(FileReadAll) file.Close Else WScript.Echo "File Open Error: file not exist!" WScript.Quit End If 

This script saves your file first in the text, and then it converts the text in it in one column. If it is needed it is in excel format, open the text file and resave, but I do not see the need.

EViews 7 txt file:

EViews 7 txt file

Das wäre richtig. Ich hätte fast 126.000 Zeilen nur in Spalte A. Die Daten werden in EViews 7 importiert, daher formatiere ich sie für Panel-Daten. nvdkgm vor 11 Jahren 0
@nvdkgm ok, siehe und teste das Skript STTR vor 11 Jahren 0
Schätzen Sie die Hilfe und die Screenshots. nvdkgm vor 11 Jahren 0