Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel macro-copy formula to entire column? | Excel Discussion (Misc queries) | |||
If data in one column, take date, add 2 days, and turn the entire column a color... | Excel Discussion (Misc queries) | |||
my column is sorted in two sections. How do I sort entire column? | Excel Discussion (Misc queries) | |||
my column is sorted in two sections. How do I sort entire column? | Excel Discussion (Misc queries) | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming |