Home > Software design >  VBA Excel Automation (search for hundreds of little WorkBooks (same number of columns) to be queued
VBA Excel Automation (search for hundreds of little WorkBooks (same number of columns) to be queued

Time:04-10

I wrote succesully in Visual Foxpro the research of the Workbooks in a specific customer's directory and subdir. Now I want, starting by the first Workbook, append the the second just below the first and so on... I wrote, attempting to have success:

xStrFName = TRIM(filemm)
oExcel.Workbooks.Open(xStrFName)
oExcel.Workbooks(2).Sheets(1).UsedRange.Copy

WITH oExcel.Workbooks(1).Sheets(1)
  loLastCell = .Cells.SpecialCells(xlLastCell)
  mcomo = .Range(m.loLastCell,m.loLastCell).Row
  mcomo = mcomo 1
  .Cells((m.mcomo,1),(m.como,7)).Paste
ENDWITH

I want to select (or directly Paste as above) the row just below the lastcell (m.mcomo 1) and therefore Paste. How may I write the correct Paste instruction (I think it will be simple but I don't know VBA......).Thanks in advance.

CodePudding user response:

Try this, see if it works:

With oExcel.Workbooks(1).Sheets(1)
 Set loLastCell = .Cells.SpecialCells(xlLastCell)
 mcomo = loLastCell.Row
 .Cells(mcomo   1, 1).PasteSpecial xlPasteAll
End With
  • Related