![]() |
sorting a worksheet with vb code
Hi,
I am building a system that enters data from worksheet -- a to worksheet --b as follows newRow = Worksheets(sheetName).Range("B65536").End(xlUp).Ro w + 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 |
sorting a worksheet with vb code
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 -- "karthik" wrote in message oups.com... Hi, I am building a system that enters data from worksheet -- a to worksheet --b as follows newRow = Worksheets(sheetName).Range("B65536").End(xlUp).Ro w + 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 |
sorting a worksheet with vb code
Thanks Paul,
Works as a gem !! warm regards karthik PCLIVE RemoveThis wrote: 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 -- "karthik" wrote in message oups.com... Hi, I am building a system that enters data from worksheet -- a to worksheet --b as follows newRow = Worksheets(sheetName).Range("B65536").End(xlUp).Ro w + 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 |
All times are GMT +1. The time now is 03:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com