Specify a certain column in a range?

El Asado

So sorry if this is really obvious, but I'm having some trouble connecting two pieces of information.

I have a one-cell range (for example, like A1) and a second, larger range (such as A1:C223). I want to be able to write some code that will make a new range using the column of the one-cell, and the number of rows of the larger range (so in this example, it would end up being A1:A223).

I want to use this specifically to create a loop later, but I'm having trouble creating this range first. Any help would be appreciated.

BruceWayne

I think I understand what you want. See if this works:

Sub test()
Dim rangeA As Range, rangeB As Range, combRange As Range

Set rangeA = Range("A1")
Set rangeB = Range("A1:C223")

Set combRange = Range(Cells(rangeB.Rows(1).Row, rangeA.Column), _
    Cells(rangeB(rangeB.Rows.Count, 1)(1).Row, rangeA.Column))

Debug.Print combRange.address

End Sub

Edit: This is a little too much perhaps, it looks like @SiddharthRout has a great solution too in the comments :D

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to specify a column range according to a formula in Excel?

From Dev

return lines containing numbers in a range in a certain column

From Dev

search a range of numbers in certain column and hide rows that aren't in the range

From Dev

return lines containing numbers in a range in a certain column but only if a column contains a certain number

From Java

How to join two dataframes for which column values are within a certain range?

From Dev

How to join two dataframes for which column values are within a certain range?

From Dev

Why is the Range.Find working for only certain column names? VBA

From Dev

Find colum with certain text and use entire column as a range in index match

From Dev

Specify width of certain columns

From Dev

Specify hinting for a certain font

From Dev

Specify hinting for a certain font

From Dev

When to specify certain Setups in Moq

From Dev

When to specify certain Setups in Moq

From Dev

SumIf certain values are in a range

From Dev

List in certain range

From Dev

CIN within certain range

From Dev

Add lists in a certain range

From Dev

Stop a number at a certain range

From Dev

Select elements within certain range per column in a 2D NumPy array

From Dev

pandas dataframe replace NaN with 0 when column name in a certain date range

From Dev

Pandas Specify time range in DatetimeIndex

From Dev

specify a range in bundler ruby version

From Dev

How to specify year range in r?

From Dev

An error when specify range for RangeValidator

From Dev

In AWK, is it possible to specify a range for operation?

From Dev

How to specify year range in r?

From Dev

specify range request length for Firefox

From Dev

Specify column separator for BCP

From Dev

Select * but group by a certain column, only for a certain column

Related Related

  1. 1

    How to specify a column range according to a formula in Excel?

  2. 2

    return lines containing numbers in a range in a certain column

  3. 3

    search a range of numbers in certain column and hide rows that aren't in the range

  4. 4

    return lines containing numbers in a range in a certain column but only if a column contains a certain number

  5. 5

    How to join two dataframes for which column values are within a certain range?

  6. 6

    How to join two dataframes for which column values are within a certain range?

  7. 7

    Why is the Range.Find working for only certain column names? VBA

  8. 8

    Find colum with certain text and use entire column as a range in index match

  9. 9

    Specify width of certain columns

  10. 10

    Specify hinting for a certain font

  11. 11

    Specify hinting for a certain font

  12. 12

    When to specify certain Setups in Moq

  13. 13

    When to specify certain Setups in Moq

  14. 14

    SumIf certain values are in a range

  15. 15

    List in certain range

  16. 16

    CIN within certain range

  17. 17

    Add lists in a certain range

  18. 18

    Stop a number at a certain range

  19. 19

    Select elements within certain range per column in a 2D NumPy array

  20. 20

    pandas dataframe replace NaN with 0 when column name in a certain date range

  21. 21

    Pandas Specify time range in DatetimeIndex

  22. 22

    specify a range in bundler ruby version

  23. 23

    How to specify year range in r?

  24. 24

    An error when specify range for RangeValidator

  25. 25

    In AWK, is it possible to specify a range for operation?

  26. 26

    How to specify year range in r?

  27. 27

    specify range request length for Firefox

  28. 28

    Specify column separator for BCP

  29. 29

    Select * but group by a certain column, only for a certain column

HotTag

Archive