Frustrating Range selection

caselton

New Member
Joined
Apr 21, 2018
Messages
13
Hi all

I have an extract from a something i'm working on

here is the code extract
Code:
Set f1 = Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 2))
Set f2 = Range(ActiveCell.Offset(0, 3), ActiveCell.Offset(0, 4))
Set f3 = Range("ActiveCell.Offset(0, 3), ActiveCell.Offset(0, 5)")

All i want to do is define the range for f3 to be for those two values only, not the full range between them
but it will not accept it.
i've tried a few different ways
below was a little test i was doing

Code:
Set ss = Range("A1, A3")
 y = Range("A1").Address
 y2 = Range("A3").Address
 Set gh = Range("y, y2")

ss works as it should
gh doesn't , no matter what i do

I'm sure i've missed something small, i'm new to VBA
Any help always appreciated
Cheers
J
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Two ways from among many:

Code:
  Set f1 = ActiveCell.Range("B1:C1")
  Set f1 = ActiveCell.Offset(, 1).Resize(, 2)
 
Upvote 0
i think you missunderstand the question

i need the f3 range to miss out a cell, say d4 and f4
i would like to select just those values , but not like this:

set test = range("d4,f4")

i would like define the cells first or use activecell command
like
y1 = range("d4")
y2 = range("f4")

set test = range("d4,f4")

but that throws out errors

Cheers for the reply though
 
Upvote 0
Code:
  With ActiveCell
    Set f3 = Union(.Offset(, 1), .Offset(, 3))
  End With
  f3.Select
 
Upvote 0
What's the reason for not using:

set test = range("d4,f4")

If you want to define single cell variables try:
Code:
Sub RangeForTwo()
Set y1 = Range("D4")
Set y2 = Range("F4")
Set test = Union(y1, y2)
test.Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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