sorting a worksheet with vb code


K

karthik

Hi,

I am building a system that enters data from worksheet --> a to
worksheet -->b as follows

newRow = Worksheets(sheetName).Range("B65536").End(xlUp).Row + 1
Worksheets(sheetName).Cells(newRow, 2).Value =
Worksheets("Dashboard").Range("K35").Value
Worksheets(sheetName).Cells(newRow, 3).Value =
Worksheets("Dashboard").Range("L35").Value
Worksheets(sheetName).Cells(newRow, 4).Value =
Worksheets("Dashboard").Range("M35").Value
Worksheets(sheetName).Cells(newRow, 5).Value =
Worksheets("Dashboard").Range("N35").Value

Now I want it to automatically sort the data based on the date in cell
E of the worksheet --> sheetName

I am currently doing this: which just returns an error (1004)

Worksheets(sheetName).Range("A10:G").Sort
Key1:=Worksheets(sheetName).Columns("E"), Order1:=xlDescending

Thanks,

Karthik
 
Ad

Advertisements

P

PCLIVE

Your range appears to be incorrect.

Worksheets(sheetName).Range("A10:G").Sort

"A10:G"

Maybe it's "A10:G100" or something like that.

Regards,
Paul
 
Ad

Advertisements


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

Top