Range resize help

Dr.Evil925

New Member
Joined
Feb 24, 2011
Messages
22
I have a range in vba defined as "FoundCell" it consists of a single cell, lets say J1. How can I resize it? I need it to be J1:J20.
Code:
Dim FoundCell As Range
Dim FoundName As Range
Application.ScreenUpdating = False
   With Worksheets("Account DB")
       With .Rows(1)
        Set FoundCell = .Find(what:=cbCust.Value, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=faulse)
            With FoundCell.EntireColumn
                Set FoundName = .Find(what:=cbName.Value, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=faulse)
                If FoundName Is Nothing Then
                    If Not IsEmpty(FoundCell.Offset(1)) Then
                    FoundCell.End(xlDown).Offset(1).Value = cbName.Value
                    Else
                    FoundCell.Offset(1).Value = cbName.Value
                    End If
                MsgBox "Added " & cbName.Value & "!"
                       FoundCell.resize(20, 0).Select
                Else
                MsgBox cbName.Value & " already exists"
                End If
            End With
        End With
    End With
Help!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
What's this?

Set FoundCell = .Find(what:=cbCust.Value, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=faulse)
With FoundCell.EntireColumn
Set FoundName = .Find(what:=cbName.Value, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=faulse)
 
Upvote 0
I have those in there to first find what column to use, and second find if the current name is already in the database.
cbCust, and cbName are combo box's in a userform.
 
Upvote 0
Hello DrEvil925,

The arguments of the Resize statement are RowSize and ColumnSize. You can not specify zero for either of these. You can however, leave it blank. Here are some examples:
Code:
FoundCell.resize(20, 1).Select

FoundCell.resize(20,).Select

FoundCell.resize(RowSize:=20).Select
Sincerely,
Leith Ross

</pre>
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top