VBA Ranges criteria

joes2580

New Member
Joined
Feb 18, 2015
Messages
36
Ok so here is my question:

In my code I have for example Range("A7:A8527").Select

My problem is, when I import the information every month to run this code, The number of lines can vary.

Can I manipulate the syntax to where it will capture the data in the cells I want no matter how many rows there are? I also want it to end at the end of the data; not go all the way down to the end of the sheet. For Ex. if I do ("A:A") the data will go down the bottom of the sheet.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I need to select the range to input formulas; then copy/paste formulas then paste values so I can sort the data.
 
Upvote 0
I need to select the range to input formulas; then copy/paste formulas then paste values so I can sort the data.

No you don't. For example...

Code:
Sub test()

With Sheets("Sheet1")
    With .Range("A1:A10")
        .Formula = "=SUM(B1:B2)"
        .Formula = .Value
    End With
End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,203,068
Messages
6,053,342
Members
444,654
Latest member
Rich Cohen

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