Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Spreadsheet Programming

Is there a program/ code I can use which will cut cells with a particular
value (text and/or number) and paste them to their particular worksheet, in
the same workbook? Also can I use this program to cut and paste the cells
adjacent to the selected cells in the same row i.e. move the whole row
beginning with this cell to a particular worksheet??

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Spreadsheet Programming

Here is a program for finding words (This & That) and copying the entire row
and pasting the results in another sheet. You just need to change the set
statements to suit your needs.

Sub Test()
Call CopyCells("This")
Call CopyCells("That")
End Sub

Sub CopyCells(ByVal strWordToFind As String)
Dim rngFirst As Range
Dim rngCurrent As Range
Dim rngFoundCells As Range
Dim rngToSearch As Range
Dim wksToSearch As Worksheet
Dim wksToPaste As Worksheet
Dim rngToPaste As Range

Set wksToSearch = Sheets("Sheet1")
Set wksToPaste = Sheets("Sheet2")
Set rngToSearch = wksToSearch.Cells
Set rngToPaste = wksToPaste.Range("A65536").End(xlUp).Offset(1, 0)
Set rngCurrent = rngToSearch.Find(strWordToFind)
If rngCurrent Is Nothing Then
MsgBox strWordToFind & " was not found"
Else
Set rngFirst = rngCurrent
Set rngFoundCells = rngCurrent.EntireRow
Do
Set rngFoundCells = Union(rngCurrent.EntireRow, rngFoundCells)
Set rngCurrent = rngToSearch.FindNext(rngCurrent)
Loop Until rngFirst.Address = rngCurrent.Address
rngFoundCells.Copy rngToPaste
End If
End Sub

--
HTH...

Jim Thomlinson


"Paul" wrote:

Is there a program/ code I can use which will cut cells with a particular
value (text and/or number) and paste them to their particular worksheet, in
the same workbook? Also can I use this program to cut and paste the cells
adjacent to the selected cells in the same row i.e. move the whole row
beginning with this cell to a particular worksheet??

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
VBA Programming [email protected] New Users to Excel 2 May 28th 08 08:38 PM
programming ernie Excel Discussion (Misc queries) 4 March 13th 06 02:06 PM
Please help with programming RandyJ Excel Programming 2 October 8th 04 10:59 PM
Programming in VB Kamyk Excel Programming 2 July 8th 04 11:02 PM
Programming lag Ernst Guckel[_3_] Excel Programming 4 June 9th 04 03:40 PM


All times are GMT +1. The time now is 08:11 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"