Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select and copy only cells with values, open an app, paste into
Hello
Writing a little macro, got partway, now I need this bit: I've got a worksheet (one of many in the workbook) called Adjust with formulae in A1:J2000 but the formulae are such that only a certain number of rows have values in them and that will vary. So, for example, today only A1:J1082 have values in them, next week it could be A1:J1200 or A1:J1010 (the cells with values will always be in one 'block'). I want to copy all the rows (from column A to J) with values in them, open Notepad, paste the values into the Notepad file and Save As C:\...ABC.txt - but C:\...ABC.txt will already exist and I'll want to discard it and replace it with the new version. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select and copy only cells with values, open an app, paste into
robzrob wrote:
Writing a little macro, got partway, now I need this bit: I've got a worksheet (one of many in the workbook) called Adjust with formulae in A1:J2000 but the formulae are such that only a certain number of rows have values in them and that will vary. So, for example, today only A1:J1082 have values in them, next week it could be A1:J1200 or A1:J1010 (the cells with values will always be in one 'block'). I want to copy all the rows (from column A to J) with values in them, open Notepad, paste the values into the Notepad file and Save As C:\...ABC.txt - but C:\...ABC.txt will already exist and I'll want to discard it and replace it with the new version. No need to involve notepad; VBA can handle text files quite easily. This stops with the first all-blank line: Sub writeNonBlanksToText() Const OUTPUTFILENAME = "C:\ABC.txt" Dim cell As Range, ro As Range, outP As String fnum = FreeFile Open OUTPUTFILENAME For Output As fnum For Each ro In Range("A1:J" & Cells.End(xlDown).Row).Rows outP = "" allBlank = True For Each cell In ro.Cells If cell.Column < 1 Then outP = outP & vbTab outP = outP & cell.Value If Len(Trim$(cell.Value)) Then allBlank = False Next If allBlank Then Exit For Print #fnum, outP Next Close fnum End Sub -- What's a little aggravated assault amongst proper European scientists? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select and copy only cells with values, open an app, paste into
On Monday, July 2, 2012 5:53:11 AM UTC+1, Auric__ wrote: robzrob wrote: Writing a little macro, got partway, now I need this bit: I've got a worksheet (one of many in the workbook) called Adjust with formulae in A1:J2000 but the formulae are such that only a certain number of rows have values in them and that will vary. So, for example, today only A1:J1082 have values in them, next week it could be A1:J1200 or A1:J1010 (the cells with values will always be in one 'block'). I want to copy all the rows (from column A to J) with values in them, open Notepad, paste the values into the Notepad file and Save As C:\...ABC.txt - but C:\...ABC.txt will already exist and I'll want to discard it and replace it with the new version. No need to involve notepad; VBA can handle text files quite easily. This stops with the first all-blank line: Sub writeNonBlanksToText() Const OUTPUTFILENAME = "C:\ABC.txt" Dim cell As Range, ro As Range, outP As String fnum = FreeFile Open OUTPUTFILENAME For Output As fnum For Each ro In Range("A1:J" & Cells.End(xlDown).Row).Rows outP = "" allBlank = True For Each cell In ro.Cells If cell.Column < 1 Then outP = outP & vbTab outP = outP & cell.Value If Len(Trim$(cell.Value)) Then allBlank = False Next If allBlank Then Exit For Print #fnum, outP Next Close fnum End Sub -- What's a little aggravated assault amongst proper European scientists? Wonderful. Thanks very much. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Select cells copy/paste and repeat x times | Excel Programming | |||
Copy/Paste how to avoid the copy of formula cells w/o calc values | Excel Discussion (Misc queries) | |||
Macro to open workbook and copy and paste values in to orig workbo | Excel Worksheet Functions | |||
Copy & Paste Unique Cells Values | Excel Programming | |||
Select Visible Cells only copy & Paste | Excel Programming |