Count Max Number of Columns?

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
I just want to select max number of columns to replace '0's with ""
I got the above part....
Using dCount to count the max no. of columns...
I'm stuck on how to select max number of Columns. Because it is by alphabet(a...b...d...e...)
Any idea guys?


Code:
Private Sub CommandButton1_Click()
DCount = Range("c2").Value
    [COLOR="Red"][B]Column("1:" & DCount & "").Select[/B][/COLOR]
    'Selection.Replace What:="0", Replacement:="", LookAt:=xlPart, _
    '    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    '    ReplaceFormat:=False
End Sub
7-Eleven 09 Jul 2008.xls
ABCDEFG
1OrderDate:09-07-08
2DeliveryDate09-07-0816
3PostingDate09-07-08
4UnitPrice
5ItemNoRFG-151RFG-158RFG-152RFG-151
6ProductNameExternalDocumentNo.17212*CHIXROLL&CHEESE1729*CALIFORNIATUNA1715*CLUBSANDWICH1714*ROASTMEXICANECHIX
7C0125-1127-ELEVEN112-00*KKWOMENHOS0000
8C0125-2217-ELEVEN221-00*OWENRD0000
9C0125-4687-ELEVENSTORE4680000
10C0125-1957-ELEVEN195-00*HOANAMBUIL0000
11C0125-4607ELEVENSTORE4600000
12C0125-4567-ELEVENSTORE4560000
Order Template
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Are you looking for something like this?
Code:
    DCount = ActiveCell.SpecialCells(xlLastCell).Address
    Range("A1:" & DCount).Select
 
Upvote 0
w0w! your method is alot alot alot better!
I've been using CountA formulas for the past 1 month!

Thanks man! you chnaged my programming style
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

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