Conditional selection of two column, csv file

  • Thread starter Thread starter Will
  • Start date Start date
W

Will

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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top