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: 6
Default So close and yet... (Pros Only)

....so far.

I have a spreadsheet 5000 deep and 90 across. I need the
code below to launch an input box so that when I enter a
value into this box I want any row on which the value
occours to be cut and pasted into a new sheet, all the
while cells/rows on the original sheet are moved upwards.

I'm almost there but I'm left scratching my head.

Any help would be appreciated...

Public Sub transfer()
Worksheets("Sheet1").Activate
Dim lastrow As Long
Dim lastcol As Long
Dim sString As String
sString = InputBox("ENTER YOUR VALUE: ANY ROW ON
WHICH THIS VALUE IS FOUND WILL BE COPIED TO A NEW SHEET")
If sString = "" Then
MsgBox "No search criteria requested.", vbOKOnly +
vbInformation, "Cancel is pressed."
Exit Sub
End If

lastrow = ActiveSheet.UsedRange.Rows.Count
lastcol = ActiveSheet.UsedRange.Columns.Count
Application.ScreenUpdating = False
Dim ir As Long, ic As Long, rd As Long
For ir = lastrow To 1 Step -1
For ic = lastcol To 1 Step -1
Cells(ir, ic).Activate
If UCase(Cells(ir, ic).Value) = UCase(sString) Then
Rows(ir).Copy Destination:=Sheets
(yournewsheet).Range("A1").End(xlDown).Offset(1, 0)
Rows(ir).Delete Shift:=xlUp
ir = ir - 1
ic = lastcol + 1
rd = rd + 1
End If
Next ic
Next ir
Application.ScreenUpdating = True
MsgBox "You have deleted: " & rd & " rows"
End Sub

Cheers

Gordon.
 
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
Easy one for you pros! sjs Excel Worksheet Functions 4 November 14th 07 09:36 PM
Easy one for the Pros! sjs Excel Worksheet Functions 4 November 14th 07 07:18 PM
Pros and Cons of embedding Excel Workbook object in PPT Presentati Barb Reinhardt Excel Discussion (Misc queries) 0 May 29th 07 03:04 PM
Help Excel Data manipulation Pros: Something like a Vlookup with a Sum Function vipjun Excel Worksheet Functions 4 June 9th 06 08:56 PM
Excel as a development Platform? pros and cons? Freddy[_4_] Excel Programming 3 November 17th 03 10:48 AM


All times are GMT +1. The time now is 06:32 PM.

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

About Us

"It's about Microsoft Excel"