Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
code for sorting Jack Sons Excel Discussion (Misc queries) 4 September 29th 09 08:23 AM
Sorting Master Worksheet to Regional Worksheet teapot10 Excel Worksheet Functions 3 April 14th 08 07:08 PM
Sorting a range on another worksheet without selecting the worksheet [email protected] Excel Programming 1 December 21st 06 11:06 PM
Sorting code MarkN Excel Programming 5 January 12th 06 01:32 PM
Sorting with code JohnDK[_2_] Excel Programming 1 November 3rd 05 09:09 PM


All times are GMT +1. The time now is 07:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"