Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default HOW TO RUN MACRO ON ENTIRE COLUMN

I have a simple format macro that runs on a single cell. I need example code
to have it run on either selection or entire column. -JEFF-
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default HOW TO RUN MACRO ON ENTIRE COLUMN

Hi Jeff

if you'ld like to post your code it would make it easier for us to give a
useful answer :)

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"-JEFF-" wrote in message
...
I have a simple format macro that runs on a single cell. I need example
code
to have it run on either selection or entire column. -JEFF-



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default HOW TO RUN MACRO ON ENTIRE COLUMN

Something like

For i = 1 To Cells(Rows.Count,"C").End(xlUp).Row
thisCell = Cells(i,"C").Value
' do your stuff on thisCell
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"-JEFF-" wrote in message
...
I have a simple format macro that runs on a single cell. I need example

code
to have it run on either selection or entire column. -JEFF-



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default HOW TO RUN MACRO ON ENTIRE COLUMN

Here's my code. I need to be able to run this either on a selection of cells
or on a column. Either one will do.

Sub JSN_format()
Dim l_tmp
Dim r_tmp
Dim tmp_jsn
tmp_jsn = ActiveCell.Value
If Len(tmp_jsn = 13) And IsNumeric(Left(tmp_jsn, 1)) Then
tmp_jsn = Right(tmp_jsn, 8)
End If
If Not InStr(tmp_jsn, "-") Then
l_tmp = Left(tmp_jsn, 4)
r_tmp = Right(tmp_jsn, 4)
tmp_jsn = l_tmp + "-" + r_tmp
ActiveCell.Value = tmp_jsn
End If
End Sub



"JulieD" wrote:

Hi Jeff

if you'ld like to post your code it would make it easier for us to give a
useful answer :)

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"-JEFF-" wrote in message
...
I have a simple format macro that runs on a single cell. I need example
code
to have it run on either selection or entire column. -JEFF-




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default HOW TO RUN MACRO ON ENTIRE COLUMN

Untested

Sub JSN_format()
Dim l_tmp
Dim r_tmp
Dim tmp_jsn
Dim iLastRow As Long
Dim i As Long

With Activecell
iLastRow = Cells(Rows.Count, .Column).End(xlUp).Row
For i = 1 To iLastRow
tmp_jsn = Cells(i,.Column).Value
If Len(tmp_jsn = 13) And IsNumeric(Left(tmp_jsn, 1)) Then
tmp_jsn = Right(tmp_jsn, 8)
End If
If Not InStr(tmp_jsn, "-") Then
l_tmp = Left(tmp_jsn, 4)
r_tmp = Right(tmp_jsn, 4)
tmp_jsn = l_tmp + "-" + r_tmp
Cells(i,.Column).Value = tmp_jsn
End If
End With
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"-JEFF-" wrote in message
...
Here's my code. I need to be able to run this either on a selection of

cells
or on a column. Either one will do.

Sub JSN_format()
Dim l_tmp
Dim r_tmp
Dim tmp_jsn
tmp_jsn = ActiveCell.Value
If Len(tmp_jsn = 13) And IsNumeric(Left(tmp_jsn, 1)) Then
tmp_jsn = Right(tmp_jsn, 8)
End If
If Not InStr(tmp_jsn, "-") Then
l_tmp = Left(tmp_jsn, 4)
r_tmp = Right(tmp_jsn, 4)
tmp_jsn = l_tmp + "-" + r_tmp
ActiveCell.Value = tmp_jsn
End If
End Sub



"JulieD" wrote:

Hi Jeff

if you'ld like to post your code it would make it easier for us to give

a
useful answer :)

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"-JEFF-" wrote in message
...
I have a simple format macro that runs on a single cell. I need

example
code
to have it run on either selection or entire column. -JEFF-








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default HOW TO RUN MACRO ON ENTIRE COLUMN

Thank you Bob. I just got it running with your first suggestion. I see a
couple of differences between you first and second post. I'll run with it.
-JEFF-

"Bob Phillips" wrote:

Untested

Sub JSN_format()
Dim l_tmp
Dim r_tmp
Dim tmp_jsn
Dim iLastRow As Long
Dim i As Long

With Activecell
iLastRow = Cells(Rows.Count, .Column).End(xlUp).Row
For i = 1 To iLastRow
tmp_jsn = Cells(i,.Column).Value
If Len(tmp_jsn = 13) And IsNumeric(Left(tmp_jsn, 1)) Then
tmp_jsn = Right(tmp_jsn, 8)
End If
If Not InStr(tmp_jsn, "-") Then
l_tmp = Left(tmp_jsn, 4)
r_tmp = Right(tmp_jsn, 4)
tmp_jsn = l_tmp + "-" + r_tmp
Cells(i,.Column).Value = tmp_jsn
End If
End With
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"-JEFF-" wrote in message
...
Here's my code. I need to be able to run this either on a selection of

cells
or on a column. Either one will do.

Sub JSN_format()
Dim l_tmp
Dim r_tmp
Dim tmp_jsn
tmp_jsn = ActiveCell.Value
If Len(tmp_jsn = 13) And IsNumeric(Left(tmp_jsn, 1)) Then
tmp_jsn = Right(tmp_jsn, 8)
End If
If Not InStr(tmp_jsn, "-") Then
l_tmp = Left(tmp_jsn, 4)
r_tmp = Right(tmp_jsn, 4)
tmp_jsn = l_tmp + "-" + r_tmp
ActiveCell.Value = tmp_jsn
End If
End Sub



"JulieD" wrote:

Hi Jeff

if you'ld like to post your code it would make it easier for us to give

a
useful answer :)

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"-JEFF-" wrote in message
...
I have a simple format macro that runs on a single cell. I need

example
code
to have it run on either selection or entire column. -JEFF-






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default HOW TO RUN MACRO ON ENTIRE COLUMN


"-JEFF-" wrote in message
...
Thank you Bob. I just got it running with your first suggestion. I see a
couple of differences between you first and second post. I'll run with

it.

Hi Jeff,

I adapted to your code :-)

Bob


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel macro-copy formula to entire column? kfboudreau Excel Discussion (Misc queries) 2 February 9th 07 08:21 PM
If data in one column, take date, add 2 days, and turn the entire column a color... [email protected] Excel Discussion (Misc queries) 6 August 24th 06 03:58 AM
my column is sorted in two sections. How do I sort entire column? Elcar Excel Discussion (Misc queries) 0 February 13th 06 08:41 PM
my column is sorted in two sections. How do I sort entire column? Bob Umlas, Excel MVP Excel Discussion (Misc queries) 0 February 13th 06 08:41 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM


All times are GMT +1. The time now is 12:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"