Select and Save as

  • Thread starter Thread starter DaveM
  • Start date Start date
D

DaveM

Hi all

Can anyone help me with some code please

My data is in A1 to J1100
in column B there are random sequences of number

1
2
3
4
1
2
3
4
5
1
2
3
1
2
3
4
5
6

How can I select in column B the sequence 1 to 4 , then highlight B1 to J4
and save as a html file to c:\
With the file name always to the left of the 1, A1. A5, A10 etc, and when
the code finishes goto B5 and start the code again.

Thanks in advance

Dave
 
Something like (totally untested, just to start you off):

Dim i As Long
For i = 1 To 1097 Step 4
Set wb = Workbooks.Add
Set ws = wb.ActiveSheet
ThisWorkbook.ActiveSheet.Cells(i, 2).Resize(, 9).Copy ws.Cells(1, 1)
wb.SaveAs Cells(i, 1), xlHtml
wb.Close False
Next

__________________________________________________________________________
 
Thanks for your help

run-time error 1004

in debug below was highlighted yellow

wb.SaveAs Cells(i, 1), xlHtml

a new workbook was created with data from another location than selected.
 
Does column A contain the fully-qualified filename that you want to save the
file as? With the full path?
________________________________________________________________________
 
All OK Thanks Vasant


Vasant Nanavati said:
Does column A contain the fully-qualified filename that you want to save
the file as? With the full path?
________________________________________________________________________
 

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