Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Conditional selection of two column, csv file

Hi all again,

does anyone know VBA code to select value ranges both in
colum A and B, based on not NULL values in colum B. In
other words, select A and B according how many values in
B. And then save it as csv file.
exp.: Select A and B but only where B= 2,3,4, not (A:B)

A | B
-------
1 | 2
1 | 3
1 | 4
3
4

Thank you all in advance,

Will

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Conditional selection of two column, csv file

Will,

Try something like:

Sub Export_csv()
Dim cntr As Long
Range("A1").Select
cntr = 0
'put a valid path and the desired filename in the next line
Open "C:\SomeFolder\SomeFile.csv" For Output As #1
Do
If Not IsEmptyl(Activecell.Offset(cntr,1)) Then
Print #1, Activecell.Offset(cntr,0) & "," &
Activecell.Offset(cntr,1) & ","
End If
cntr = cntr + 1
If IsEmpty(Activecell.Offset(cntr,0)) Then Exit Do
Loop
Close #1
End Sub

HTH,
Nikos


"Will" wrote in message
...
Hi all again,

does anyone know VBA code to select value ranges both in
colum A and B, based on not NULL values in colum B. In
other words, select A and B according how many values in
B. And then save it as csv file.
exp.: Select A and B but only where B= 2,3,4, not (A:B)

A | B
-------
1 | 2
1 | 3
1 | 4
3
4

Thank you all in advance,

Will



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional selection of two column, csv file

Nikos, thanks a lot,

I need to learn VBA, what book would you recommend?

Greece is the beautiful country and great people!!!
It is important that Greece will host 2004 Olympic, the
place were it was born. I wish I had time to travel to
your country, perhaps some day.

Thanks again,
Sergey

-----Original Message-----
Will,

Try something like:

Sub Export_csv()
Dim cntr As Long
Range("A1").Select
cntr = 0
'put a valid path and the desired filename in the next

line
Open "C:\SomeFolder\SomeFile.csv" For Output As #1
Do
If Not IsEmptyl(Activecell.Offset(cntr,1)) Then
Print #1, Activecell.Offset(cntr,0) & "," &
Activecell.Offset(cntr,1) & ","
End If
cntr = cntr + 1
If IsEmpty(Activecell.Offset(cntr,0)) Then Exit Do
Loop
Close #1
End Sub

HTH,
Nikos


"Will" wrote in

message
...
Hi all again,

does anyone know VBA code to select value ranges both in
colum A and B, based on not NULL values in colum B. In
other words, select A and B according how many values in
B. And then save it as csv file.
exp.: Select A and B but only where B= 2,3,4, not (A:B)

A | B
-------
1 | 2
1 | 3
1 | 4
3
4

Thank you all in advance,

Will



.

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
Conditional Formating Based on Selection in a Combo Box adrian007uk Excel Discussion (Misc queries) 4 December 11th 09 08:54 AM
Conditional Selection [email protected] Excel Worksheet Functions 1 June 5th 07 03:00 AM
Formatting (conditional?) a drop down box selection Judithj Excel Discussion (Misc queries) 3 April 9th 07 09:28 PM
XL2K - Conditional Formatting relative to cell selection Lezh Excel Discussion (Misc queries) 3 December 31st 05 09:56 AM
Conditional Formatting and selection Kristin N Excel Discussion (Misc queries) 2 September 15th 05 06:27 PM


All times are GMT +1. The time now is 10:21 PM.

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"