Fiat Coupe Forum
- Founded by Kayjey & James Northam
- Funded by the Club for the benefit of all owners
Fiat Coupe Club UK
join the club
Fiat Coupe Forum
 
» Announced
    Posting images


» Related sites
    Main club site
    fiatcoupe.net


» External data
    owners listed
 
Who's Online Now
2 registered members (Jamiepm, slicer), 198 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Forum Statistics
Forums69
Topics113,592
Posts1,340,998
Members1,799
Most Online731
Jan 14th, 2020
Top Posters(All Time)
barnacle 33,550
stan 32,122
Theresa 23,299
PeteP 21,510
bockers 21,071
JimO 17,917
Nigel 17,367
Edinburgh 16,769
RSS Feeds
Club Events
Club Information
Track Events
Rolling Road/RWYB
Social Events
Non-UK Events
Coupé Related Chat
Coupé Spotting
Coupé News/Press
Buying/Selling Advice
Insuring a Coupé
Basic FAQ's
How to Guides
Forum Issues
Technical Problems
General Maintenance
Styling
Tuning
Handling
ICE and Alarm
Coupés for Sale
Coupés Wanted
Parts for Sale
Parts Wanted
Group Buys
Business Forum
Other Vehicles for Sale/Wanted
Other Items for Sale/Wanted
Haggling/Offers
Ebay links
Other Cars
Other Websites
General Chat
Previous Thread
Next Thread
Print Thread
EXCEL VBA Question #1622338
26/06/2018 13:16
26/06/2018 13:16

E
elder81
Unregistered
elder81
Unregistered
E



Hi all,

I have data that I need to format using conditional formatting as part of an automated process.

I need to select all data in one column, but there are gaps in the data.

I have tried using the following code, but it just selects the entire column. I only want to go to the last row with data in it if that makes sense?

Current VBA code:
Sub trest()
Dim DataRange As Range

Set DataRange = Range("I1:I" & Cells.SpecialCells(xlCellTypeLastCell).Row)
DataRange.Select
End Sub

Anyone know how to correct this code?

Re: EXCEL VBA Question [Re: ] #1622339
26/06/2018 13:26
26/06/2018 13:26
Joined: Dec 2005
Posts: 17,367
Staffordshire
Nigel Offline
Forum veteran
Nigel  Offline
Forum veteran

Joined: Dec 2005
Posts: 17,367
Staffordshire
Is the last row with data in it variable? (ie does the number of rows increase / decrease?)


[Linked Image]
Re: EXCEL VBA Question [Re: ] #1622340
26/06/2018 13:27
26/06/2018 13:27

E
elder81
Unregistered
elder81
Unregistered
E



Yes and that is the issue.

Re: EXCEL VBA Question [Re: ] #1622341
26/06/2018 13:34
26/06/2018 13:34
Joined: Dec 2005
Posts: 17,367
Staffordshire
Nigel Offline
Forum veteran
Nigel  Offline
Forum veteran

Joined: Dec 2005
Posts: 17,367
Staffordshire
try this (only lifted from t'internet - not my own work)

Originally Posted By Some VBA from the intenet

Sub Select_Column()
Dim ac As Integer
Dim lastr As Long
Dim sh As Worksheet


Set sh = ActiveSheet
ac = ActiveCell.Column
lastr = sh.Cells(Rows.Count, ac).End(xlUp).Row
Range(Cells(2, ac), Cells(lastr, ac)).Select
End Sub


[Linked Image]

Powered by UBB.threads™ PHP Forum Software 7.7.1
(Release build 20190129)
PHP: 7.3.33 Page Time: 0.012s Queries: 15 (0.006s) Memory: 0.7479 MB (Peak: 0.7972 MB) Data Comp: Off Server Time: 2024-04-24 00:06:15 UTC