Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-20-2012, 08:58 AM
Catalin.B Catalin.B is offline Macro to copy specific columns in Excel from another spreadsheet Windows Vista Macro to copy specific columns in Excel from another spreadsheet Office 2010 32bit
Expert
 
Join Date: May 2011
Location: Iaşi, România
Posts: 386
Catalin.B is on a distinguished road
Default

You can try this code. The code is checking the column C ; if there are no more data in this column rows, the code stops, so i couldn't find a reason to put that "/" in destination column A.
Code:
Sub OpenCopy()
Dim OpenFile, fileName As String, LastRow As Long, i As Integer
OpenFile = Application.GetOpenFilename("Excel files,*.xl*", _
                           1, "Select destination file", , False)
       Workbooks.Open fileName:=OpenFile
       fileName = ActiveWorkbook.Name
       Application.ScreenUpdating = False
       Application.DisplayAlerts = False
     LastRow = ThisWorkbook.Sheets("Sheet1").Cells(ThisWorkbook.Sheets("Sheet1").Rows.Count, "C").End(xlUp).Row
                           
      For i = 2 To LastRow
      ThisWorkbook.Sheets("Sheet1").Cells(i, "C").Copy
      ActiveWorkbook.Sheets("Sheet1").Cells(i, "A").Select
      ActiveWorkbook.Sheets("Sheet1").Paste
      
      ThisWorkbook.Sheets("Sheet1").Range("I" & i & ":N" & i).Copy
      ActiveWorkbook.Sheets("Sheet1").Cells(i, "N").Select
      ActiveWorkbook.Sheets("Sheet1").Paste
      Next i
      Application.CutCopyMode = False
      Workbooks(fileName).Close savechanges:=True
      
      Application.DisplayAlerts = True
      Application.ScreenUpdating = True
       
End Sub
This topic should be in Excel programming forum, i guess...
Cheers, Catalin
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to separate specific columns from the data kumar Word 1 06-04-2012 01:46 PM
Macro to copy specific columns in Excel from another spreadsheet Macro: Exporting Data to a LEGIBLE Excel Spreadsheet jeffcoleky Word VBA 6 05-08-2012 08:24 AM
Adding columns in specific rows only mhays Excel 5 01-17-2012 09:13 AM
CAUTION!! Sorting a spreadsheet with hidden columns will trash your data. psmaster@earthlink.net Excel 0 11-24-2009 11:54 AM
Macro to copy specific columns in Excel from another spreadsheet Looking for a specific spreadsheet DivideByZer0 Excel 3 11-10-2009 05:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:44 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft