excel - vba looping through range writing to csv -


i have written macro supposed loop through range , if range contains number copy offset cells csv or sheet. when excute code runs through out breaking there no output within text file nor there error messages.

i dont know going on? pointers? please thanks.

dim rng range, cell range  dim ofset string  dim filepath string   set rng = range("f1:f100")   each cell in rng    if iserror(cell)      'msgbox "cell " & cell.address & " contains error"    elseif cell.value > 0      ofset = cell.offset(, -2).resize(, 2).select 'gives b1:c1      ' copy range text file      filepath = application.defaultfilepath & "\authors.csv"      open filepath output #2       write #2, cell.value & ofset      close #2     end if next cell msgbox "the values have been copied" 

is file date updated on each pass?

there may null string @ end of data. if you're not wanting last value, change this:

open filepath output #2  

to

open filepath append #2   dim rng range, cell range  dim ofset string  dim filepath string   set rng = range("f1:f100")   each cell in rng    if iserror(cell)      'msgbox "cell " & cell.address & " contains error"    elseif cell.value > 0      ofset = cell.offset(, -2).resize(, 2).select 'gives b1:c1      ' copy range text file      filepath = application.defaultfilepath & "\authors.csv"      open filepath output #2       ovalues = ""     each c in ofset       ovalues=ovalues & c.value     next      write #2, cell.value & ovalues     close #2     end if  next cell   msgbox "the values have been copied" 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -