Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 24
Default Defining cells that macro will change

I just installed a macro and want to have the range of cells that it will
update to be defined in the macro. Here is the macro:

Sub TRIMALL_alternate()
'Dave Peterson, programming, 2002-08-17

Dim myrange As Range
Dim myCol As Range

Set myrange = Intersect(ActiveSheet.UsedRange, Selection)
If myrange Is Nothing Then Exit Sub
Application.ScreenUpdating = False

myrange.Replace What:=Chr(160), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False

For Each myCol In myrange.Columns
If Application.CountA(myCol) 0 Then
myCol.TextToColumns Destination:=myCol(1), _
DataType:=xlFixedWidth, FieldInfo:=Array(0, 1)
End If
Next myCol
Application.ScreenUpdating = True
End Sub

I want to have it select D4:L178 but I can't figure out where to define
this. If I select the range and run the macro it works. I would appreciate
any help.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Defining cells that macro will change

Change Set myrange = Intersect(ActiveSheet.UsedRange, Selection) to

Set myrange = ActiveSheet.Range("D4:L178")


Gord Dibben MS Excel MVP

On Tue, 18 Aug 2009 14:32:01 -0700, John K
wrote:



I just installed a macro and want to have the range of cells that it will
update to be defined in the macro. Here is the macro:

Sub TRIMALL_alternate()
'Dave Peterson, programming, 2002-08-17

Dim myrange As Range
Dim myCol As Range

Set myrange = Intersect(ActiveSheet.UsedRange, Selection)
If myrange Is Nothing Then Exit Sub
Application.ScreenUpdating = False

myrange.Replace What:=Chr(160), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False

For Each myCol In myrange.Columns
If Application.CountA(myCol) 0 Then
myCol.TextToColumns Destination:=myCol(1), _
DataType:=xlFixedWidth, FieldInfo:=Array(0, 1)
End If
Next myCol
Application.ScreenUpdating = True
End Sub

I want to have it select D4:L178 but I can't figure out where to define
this. If I select the range and run the macro it works. I would appreciate
any help.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 24
Default Defining cells that macro will change

Thanks, that worked.

"Gord Dibben" wrote:

Change Set myrange = Intersect(ActiveSheet.UsedRange, Selection) to

Set myrange = ActiveSheet.Range("D4:L178")


Gord Dibben MS Excel MVP

On Tue, 18 Aug 2009 14:32:01 -0700, John K
wrote:



I just installed a macro and want to have the range of cells that it will
update to be defined in the macro. Here is the macro:

Sub TRIMALL_alternate()
'Dave Peterson, programming, 2002-08-17

Dim myrange As Range
Dim myCol As Range

Set myrange = Intersect(ActiveSheet.UsedRange, Selection)
If myrange Is Nothing Then Exit Sub
Application.ScreenUpdating = False

myrange.Replace What:=Chr(160), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False

For Each myCol In myrange.Columns
If Application.CountA(myCol) 0 Then
myCol.TextToColumns Destination:=myCol(1), _
DataType:=xlFixedWidth, FieldInfo:=Array(0, 1)
End If
Next myCol
Application.ScreenUpdating = True
End Sub

I want to have it select D4:L178 but I can't figure out where to define
this. If I select the range and run the macro it works. I would appreciate
any help.



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
defining names in a macro guidop12 Excel Discussion (Misc queries) 6 August 28th 08 11:56 PM
Defining cells for cross-referencing Questor Excel Discussion (Misc queries) 0 August 10th 08 06:03 PM
Change background for ALL charts without custom defining all chart aneasiertomorrow Charts and Charting in Excel 4 September 29th 07 01:45 AM
Defining Cells to be Added using SUMIF Pappey New Users to Excel 3 March 25th 05 05:05 PM
Drop down defining content of a range of cells philm13 Links and Linking in Excel 5 March 25th 05 03:31 PM


All times are GMT +1. The time now is 04:58 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"