Thread: Resize Problem
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Resize Problem

The .resize(0,1) says to resize that single cell to a range of 0 rows by 1
column. That doesn't exist. Maybe you meant .resize(1,2) (one row by 2
columns???)

I think I'd add just a bit of a check:

Dim FoundCell As Range

Set FoundCell = Cells.Find(what:="Pending", after:=ActiveCell, _
LookIn:=xlFormulas, lookat:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then
MsgBox "not found"
Else
If FoundCell.Column = ActiveSheet.Columns.Count Then
MsgBox "nothing to the right!"
Else
FoundCell.Resize(1, 2).EntireColumn.Cut
FoundCell.Offset(0, 3).EntireColumn.Insert Shift:=xlToRight
End If
End If

And I think you meant .offset(0,3) for the insertion, too.

But test it to see if it does what you want.

GregR wrote:

I have this code which errors on the resize line

Cells.Find(what:="Pending", after:=ActiveCell, LookIn:=xlFormulas,
lookat:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

ActiveCell.Resize(0, 1).Select
Selection.EntireColumn.Cut
ActiveCell.Offset(0, 1).Select
Selection.Insert Shift:=xlToRight

What the desired result is, look for cell with "Pending", select that
cell and the one to the right, cut both those columns and move them one
to the right. TIA

Greg


--

Dave Peterson