LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Input box with dropdown list of all sheets

Greetings all. I am working on a macro to take an active row, cut it, then
insert it into a new location, sort the target, then return to the starting
sheet and delete the empty row. The target sheet is a user prompt, where the
user types in the name of the target sheet. I would like for the input box
to open with a dropdown list of all the sheets in the workbook. Also, I
found that in some places I could perform action on the target worksheet
without activating it, like Sheets(Target).Range.some action. But then for
others I have to activate it, so I just activated it from the start. Is
there a way to perform the actions on the target without activating it?
Below is the macro with some comments. I'm still learning, so there are
probably things I am doing that are not the best way to do it, but I try
everything until something works, then I stop. Thank you.

Greg

Sub MoveJobs()

'Get the name of the active sheet so I can come back to it
Dim ActSheet As String
Dim ActCell As String
ActCell = ActiveCell.Address
ActSheet = ActiveSheet.Name

'Get the name of the target sheet
'I would like the imput box to have a drop down menu of all the sheets
'so the user does not have to enter it
Dim Target As String
Target = InputBox("Move where?")

'Move the selection to the first data row in the target sheet
Dim SheetName As Variant
ActiveCell.EntireRow.Select
Selection.Cut
Sheets(Target).Rows("2:2").Insert Shift:=xlDown
lastrow = Sheets(Target).[B65000].End(xlUp).Row

'Delete any rows where column C is blank
'I tried this method to delete the cut row once back on
'the starting sheet, but sometimes it leaves rows.
'If I run it again, it will delete the row from last run, but
'not the new one. It works here though
Sheets(Target).Activate
LstRow = [C65000].End(xlUp).Row
Set MyRng = Range("C2:C" & LstRow)
For Each MyCell In MyRng
If MyCell.Value = "" Then
MyCell.EntireRow.Delete
End If
Next MyCell

'Reset the last row
LstRow = [C65000].End(xlUp).Row

'Resort the selection
Rows("2:" & LstRow).Sort Key1:=Range("B2"), Order1:=xlAscending,
Key2:=Range("C2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal

'Go back to the starting sheet
Sheets(ActSheet).Activate

'Reset the last row
LstRow = [C65000].End(xlUp).Row

'Delete the blanks
'I tried this method on the target sheet, but it kept giving errors
'I can not figure out why it works in one place but not the other
'Basically I want one method that works everywhere, every time.
Range("C2:C" &
LstRow).Cells.SpecialCells(xlCellTypeBlanks).Entir eRow.Delete

'Return to the starting point
Range(ActCell).Select

End Sub
 
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
Dropdown List That Accepts Other User Input GEdwards Excel Discussion (Misc queries) 5 April 5th 10 05:45 AM
create a dropdown list for data input YuXuan-ji Excel Programming 1 June 22nd 07 05:14 PM
result of selecting from the dropdown list should be a dropdown list No News Excel Worksheet Functions 0 July 5th 06 04:09 PM
Make input in one column determine dropdown list in another. gettin-older Excel Discussion (Misc queries) 4 November 13th 05 10:42 PM
How to make an input in one column determine dropdown list in anot gettin-older Excel Worksheet Functions 6 November 13th 05 09:34 PM


All times are GMT +1. The time now is 12:07 PM.

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"