View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
sebastienm sebastienm is offline
external usenet poster
 
Posts: 694
Default Moving data between worksheets in VBA

Hi Mike,
Try:
'-------------------------------------
Sub test()
Dim WshS As Worksheet, WshD As Worksheet 'Source, Destination sheets
Dim Rg, RgS As Range, RgD As Range 'a range, source, dest. ranges

Set WshS = Worksheets("sheet1")
Set RgS = WshS.Range("A:A")

Set Rg = RgS.Find(what:="=", after:=RgS.Cells(RgS.Cells.Count),
LookIn:=xlValues, lookat:=xlWhole)
If Rg Is Nothing Then 'doesn't exist
MsgBox "Cannot find =."
Else
'add a sheet
Set WshD = Worksheets.Add
Set Rg = Range(Rg.Offset(1, 0), Rg.Parent.Cells(65536,
Rg.Column).End(xlUp))
Application.CutCopyMode = False
Rg.Copy WshD.Range("A1")
End If
End Sub
'-------------------------------------------

Regards,
Sebastien


"Mike" wrote:

Hi all,

I'm trying to evaluate a list in a column. When I reach a row that contains
a "=", I'd like to create a new worksheet and cut and paste all the entries
following into that new sheet.

For example:

Sheet 1:
Monkeys
Cinnamon
Car Keys
=
Root Beer

Sheet 2:
Root Beer

Any thoughts on the best way to approach the code?

Thanks in advance, this forum is amazing!

Mike