LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default How to copy a highlighted row

The following will create a CSV file for use in another application
with your data (instrument readings?). During the run, if you have
old file in your temp directory with current sheetname you will be
asked if you want to replace it (Yes), at the end your file is brought up
in Notepad for your review.

Sub Macro20()
Dim filename As String, RC As Long
filename = "c:\temp\" & _
Replace(Application.ActiveSheet.Name, " ", "") & ".csv"

ActiveSheet.Copy 'creates a new workbook with one sheet
Cells.Select 'select ALL cells
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select 'reduce to only once cell selected

ActiveWorkbook.SaveAs filename:=filename, _
FileFormat:=xlCSV, CreateBackup:=False
'-- activeworkbook is the newly copied worksheet's workbook (.CSV)
ActiveWorkbook.Close savechanges:=False
RC = Shell("Notepad " & filename, 1) 'for your viewing pleasure
End Sub

The central part of the macro is based on recording a macro
Edit, Move or Copy, to book: (new book), and must place a check next to create a copy
Select ALL cells (Ctrl+A before Excel 2003, the gray button in any version)
Ctrl+G, Special, Blanks
Edit, Delete, Shift Left

For your information: Posting with your actual name would be appreciated
as would posting directly to the newsgroups rather than through spammy
websites involving vbulletin, and jelsoft software, designed to spam Google web
searches with material intended for newsgroups.
http://www.mvps.org/dmcritchie/excel/posting.htm


---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"broncoted" <broncoted. ...... wrote
I want to create a macro that reads the numbers in the highlighted [selected]
selection, while ignoring the empty cells so that when they copy it to
something else the output would be



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
deselecting a highlighted range after a VBA copy procedure Paul James[_3_] Excel Programming 6 April 25th 23 03:47 AM
Copy highlighted. sungen99 Excel Discussion (Misc queries) 1 May 5th 06 07:43 PM
Copy highlighted. sungen99[_89_] Excel Programming 1 May 4th 06 07:44 PM
Highlighted ED New Users to Excel 5 April 13th 06 09:31 PM
Macro to copy highlighted cells to csv file Martin[_23_] Excel Programming 1 March 14th 06 07:56 PM


All times are GMT +1. The time now is 10:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"