ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to copy a highlighted row (https://www.excelbanter.com/excel-programming/367314-how-copy-highlighted-row.html)

broncoted

How to copy a highlighted row
 

Hello,

Im a beginning VBA programmer here. Could someone give me an idea o
how to highlight a row of numbers and have the macro go down th
columns and check to see if a cell is empty and moving on to the nex
column if it is? Also, I would like to copy the numbers that AR
present so I could copy it to another application. Thanks

--
broncote
-----------------------------------------------------------------------
broncoted's Profile: http://www.excelforum.com/member.php...fo&userid=3640
View this thread: http://www.excelforum.com/showthread.php?threadid=56178


David McRitchie

How to copy a highlighted row
 
You could record a macro to get an idea of most of the code.
Both parts of your question are too ambiguous for me to understand.
Also what is the other application looking for -- is it a CSV file?

For instance copy your sheet
Edit, Move or copy, be sure to mark the check box to create a copy
Select all cells on the worksheet, then Ctrl+G, select blank cells,
Edit delete, shift left
File, Save As, comma separated variable file (CSV)
---
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" wrote in message
...

Hello,

Im a beginning VBA programmer here. Could someone give me an idea on
how to highlight a row of numbers and have the macro go down the
columns and check to see if a cell is empty and moving on to the next
column if it is? Also, I would like to copy the numbers that ARE
present so I could copy it to another application. Thanks!


--
broncoted
------------------------------------------------------------------------
broncoted's Profile: http://www.excelforum.com/member.php...o&userid=36401
View this thread: http://www.excelforum.com/showthread...hreadid=561789




broncoted[_2_]

How to copy a highlighted row
 

I guess what I need first is the following:

I want a user to highlight a row of information(just the part of the
row they want)

So lets say they highlight from C3 to C:10

In that range are the following information

5 (empty cell) 4 3 5 (empty cell) (empty cell) 8

I want to create a macro that reads the numbers in the highlighted
selection, while ignoring the empty cells so that when they copy it to
something else the output would be

5 4 3 5 8

I hope this makes sense.

Thanks again.




David McRitchie Wrote:
You could record a macro to get an idea of most of the code.
Both parts of your question are too ambiguous for me to understand.
Also what is the other application looking for -- is it a CSV file?

For instance copy your sheet
Edit, Move or copy, be sure to mark the check box to create a copy
Select all cells on the worksheet, then Ctrl+G, select blank cells,
Edit delete, shift left
File, Save As, comma separated variable file (CSV)
---
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"
wrote in message
...

Hello,

Im a beginning VBA programmer here. Could someone give me an idea on
how to highlight a row of numbers and have the macro go down the
columns and check to see if a cell is empty and moving on to the

next
column if it is? Also, I would like to copy the numbers that ARE
present so I could copy it to another application. Thanks!


--
broncoted

------------------------------------------------------------------------
broncoted's Profile:

http://www.excelforum.com/member.php...o&userid=36401
View this thread:

http://www.excelforum.com/showthread...hreadid=561789



--
broncoted
------------------------------------------------------------------------
broncoted's Profile: http://www.excelforum.com/member.php...o&userid=36401
View this thread: http://www.excelforum.com/showthread...hreadid=561789


David McRitchie

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





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com