Jump to content
Sign in to follow this  
BlackShadow

Jede x.te Zeile in Excel kopieren

Recommended Posts

Hallo,

habe folgedes Problem.

Hier habe ich eine XLS Tabelle gefüllt mit Daten, erste Zeile

Name, Vorname Strasse usw.

 

Wie schaff ich das nun das ich unter allen Zeilen/Datensätzen jeden 15ten weg in eine neue Tabelle verschieben/kopieren kann und diese dann Abspeichern. Hat jemand so ein Szenario schon mal gehabt.?

 

gruß und danke Frank

Share this post


Link to post
Share on other sites

Hallo,

 

Excel Sheet mit VBS (kleines Bsp. anbei) öffnen, hier kannst Du nun jede x-te Reihe wie auch immer verarbeiten. Die Eigenschaft des Objektes sollte Dir auch in VBA zur Verfügung stehen.

 

excelPath = WScript.Arguments(0)


Set objExcel = CreateObject("Excel.Application")

objExcel.DisplayAlerts = 0

REM open (path, confirmconversions, readonly)
objExcel.Workbooks.open excelPath, false, true

REM How many worksheets are in this Excel documents
workSheetCount = objExcel.Worksheets.Count

intIndex = 2

REM Loop through each worksheet
For counter = 1 to workSheetCount


Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets(counter)
REM how many columns are used in the current worksheet
usedColumnsCount = currentWorkSheet.UsedRange.Columns.Count
REM how many rows are used in the current worksheet
usedRowsCount = currentWorkSheet.UsedRange.Rows.Count

REM What is the topmost row in the spreadsheet that has data in it
top = currentWorksheet.UsedRange.Row
REM What is the leftmost column in the spreadsheet that has data in it
left = currentWorksheet.UsedRange.Column



Set Cells = currentWorksheet.Cells
REM Loop through each row in the worksheet 
For row = 0 to (usedRowsCount-1)

	REM Loop through each column in the worksheet 
	For column = 0 to usedColumnsCount-1
		REM only look at rows that are in the "used" range
		curRow = row+top
		REM only look at columns that are in the "used" range
		curCol = column+left
		REM get the value/word that is in the cell 
		word = Cells(curRow,curCol).Value
		REM display the column on the screen
		'WScript.Echo (word)



		ListUsers strDomain, word, intIndex
	Next
Next

REM We are done with the current worksheet, release the memory
Set currentWorkSheet = Nothing
Next

objExcel.Workbooks(1).Close
objExcel.Quit

Set currentWorkSheet = Nothing
REM We are done with the Excel object, release it from memory
Set objExcel = Nothing

 

Gruß, thumb

Share this post


Link to post
Share on other sites
Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte überlege Dir, ob es nicht sinnvoller ist ein neues Thema zu erstellen.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

Werbepartner:



×
×
  • Create New...