?
Solved

Have 2 sheets of data need to sort sheet 1 as sheet 2

Posted on 2007-08-08
3
Medium Priority
?
186 Views
Last Modified: 2010-03-05
Hi,

I have Sheet 1 and sheet 2 in an excel.What i want is a macro which can ask me which sheets to be sorted as which.

Which colum does it need to take in sheet 1 or sheet2 to sort.

Regards
Sharath
0
Comment
Question by:bsharath
3 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 19654860
You need to button that will prompt a inputbox that allow you to select the sheed that is goin to be sorted (in sheet1 ou sheet2) ?
0
 
LVL 11

Author Comment

by:bsharath
ID: 19668256
Yes ...

Can i have a way to do this...
0
 
LVL 13

Accepted Solution

by:
hiteshgoldeneye earned 2000 total points
ID: 19675252
'assume second sheet to be sorted as first sheet
Sub sorttwosheets()
ws1= InputBox("Enter the first sheet name") 'e.g Sheet1
ws2= InputBox("Enter the second sheet name")'e.g Sheet2
col1= InputBox("Enter the first sheet column name") 'e.g A
col2 = InputBox("Enter the first sheet column name") 'e.g A
s2row=1
   For j=1 to Sheet1.UsedRange.Rows.Count
      For k=1 to Sheet2.UsedRange.Rows.Count
         if UCase(Sheet2.Cells(k,col2)) = UCase(Sheet1.Cells(j,col1)) then
               Sheet2.Rows(s2row).Copy Destination:=Sheet2.Rows(60000)
               Sheet1.Rows(j).Copy Destination:=Sheet2.Rows(s2row)
               Sheet2.Rows(60000).Cut Destination:= Sheet2.Rows(k)
               s2row=s2row+1
        End if
     Next
   Next

End Sub
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question