Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default To Generate statements(from source) for multiple rows to destinati

HI All,

Following is my requirement
-----------------------------------
Take an workbook (for ex: Develop.xls)
1) Develop.xls has 2000 records starting from row 3
2) each row has 30 columns. some columns has data/values; some doesnt have
values
3) a set of statements has ot be generated based on the cell values.

a set of statement should be created in such a way that, cell values should
get appended in teh next line of the statement ONLY if it has value

for ex:
Cell A =102234454, Cell B is blank, Cell C has a textvalue UNITEDBROTHERS

so, in another sheet result should be generated, leaving out the blank cells
102234454
UNITEDBROTHERS

-------

so, as i said a record has 30 columns. if a record has only 20 values out of
30 columns. in another sheet 20 values should be generated line-by-line
sequentially. ie. 20 lines will be there (if all the columns has values then
30 lines will be there)

In case, if only 20 values are there for a record; 10 lines should be
skipped before generating statements for the next record.

-------------------------------------------------------------------

As mentioned above, the sheet Develop wil contain 2000 to 3000 records wil
be there. and each record will contain 30 columsn(w/o data).

assuming all cells are filled with values. then, 2000 * 30 = 60000 rows has
to be filled in anothr sheet.


after generating statements, all statements / lines in that sheet has to be
copied
to a notepad(as a single file).

Please provide assistance to perform the above actions


Thanks & Regards,
Venkat
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default To Generate statements(from source) for multiple rows to destinati

Here is some untested pseudo code that should get you started.
It assumes that there are no formulas in the worksheet to be processed and
that this worksheet is the first worksheet in the workbook. Data starting in
row 3 as you said. It further assumes that on the last row, there is data in
column A.

Sub writeData()
Dim fName As Variant, bk As Workbook
Dim cell As Range, cell1 As Range
Dim rng As Range, rng1 As Range
Dim rng2 As Range, sh As Worksheet
Dim i As Long
fName = Application.GetOpenFilename()
If fName = False Then Exit Sub
Set bk = Workbooks.Open(fName)
With bk.Worksheets(1)
.Copy
Set sh = ActiveSheet
Set rng = .Range(.Cells(3, 1), .Cells(Rows.Count, 1).End(xlUp))
End With
i = 1
For Each cell In rng
Set rng1 = cell.Resize(1, Columns.Count)
Set rng2 = Nothing
On Error Resume Next
Set rng2 = rng1.SpecialCells(xlConstants)
On Error GoTo 0
For Each cell1 In rng2
sh.Cells(i, 1) = cell1
i = i + 1
Next
Next

fName = Application.GetSaveAsFilename()
If fName = False Then Exit Sub
ActiveSheet.Parent.SaveAs fName, xlTextMSDOS
ActiveWorkbook.Close SaveChanges:=False
bk.Close SaveChanges:=False
End Sub

--
Regards,
Tom Ogilvy


"Venkatesh V" wrote:

HI All,

Following is my requirement
-----------------------------------
Take an workbook (for ex: Develop.xls)
1) Develop.xls has 2000 records starting from row 3
2) each row has 30 columns. some columns has data/values; some doesnt have
values
3) a set of statements has ot be generated based on the cell values.

a set of statement should be created in such a way that, cell values should
get appended in teh next line of the statement ONLY if it has value

for ex:
Cell A =102234454, Cell B is blank, Cell C has a textvalue UNITEDBROTHERS

so, in another sheet result should be generated, leaving out the blank cells
102234454
UNITEDBROTHERS

-------

so, as i said a record has 30 columns. if a record has only 20 values out of
30 columns. in another sheet 20 values should be generated line-by-line
sequentially. ie. 20 lines will be there (if all the columns has values then
30 lines will be there)

In case, if only 20 values are there for a record; 10 lines should be
skipped before generating statements for the next record.

-------------------------------------------------------------------

As mentioned above, the sheet Develop wil contain 2000 to 3000 records wil
be there. and each record will contain 30 columsn(w/o data).

assuming all cells are filled with values. then, 2000 * 30 = 60000 rows has
to be filled in anothr sheet.


after generating statements, all statements / lines in that sheet has to be
copied
to a notepad(as a single file).

Please provide assistance to perform the above actions


Thanks & Regards,
Venkat

Reply
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
How do I repeat rows in Excel and automatically generate new value Max Excel Discussion (Misc queries) 4 March 3rd 09 07:21 PM
How do I query a List to generate source data for a chart? WaucomaPam Excel Worksheet Functions 0 October 7th 06 01:52 AM
Create merge source in Excel, call Word to generate labels Bill G[_4_] Excel Programming 1 October 3rd 06 07:20 AM
generate multiple rows based on cell value Theresa Excel Worksheet Functions 0 May 25th 05 11:18 PM
create multiple rows using a variable in a cell as source Kevin Stecyk Excel Programming 0 October 24th 03 05:59 AM


All times are GMT +1. The time now is 07:09 AM.

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

About Us

"It's about Microsoft Excel"