Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default newsgroup advice "selecting"

1st post, btw.........
i've read a lot of advice from you wonderful MVP people advising
against having a macro "select" cells all the time, for the sake of
saving time. i don't understand exactly how you write the code without
selecting things............. could you pls. amend this code below so
that i can see how you write it without selecting things?
(pls. excuse it the code - i'm sure it could be written much more
neatly but i'm still learning! like i realize all the "extra" parts of
the paste special can be deleted - just haven't got there yet!)
thanks very much! :D
susan
----------------
Sub UpdateCount()
'
' UpdateCount Macro
' Macro recorded 1/23/2006 by Susan
'
' revised 9/19/2006 to hide "X" worksheet
'
Application.ScreenUpdating = False

Sheets("X").Visible = True
Sheets("X").Select
Columns("A:A").Select

Selection.ClearContents

Range("A1").Select
Sheets("FOR SBH ONLY").Select
Columns("B:B").Select
Selection.Copy
Sheets("X").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False

Range("A1").Select
Application.CutCopyMode = False
Selection.ClearContents

Cells.Replace What:="contractor", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="inspectors:", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="general:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="electric:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="furnace & plumbing:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="wells & excavation:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="septic:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="sub-s:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

Columns("A:A").Select

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("D3").Select

ActiveWindow.SelectedSheets.Visible = False
Sheets("FOR SBH ONLY").Select
Range("A1").Select

Application.ScreenUpdating = True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default newsgroup advice "selecting"

Sub UpdateCount()
'
' UpdateCount Macro
' Macro recorded 1/23/2006 by Susan
'
' revised 9/19/2006 to hide "X" worksheet
'
Application.ScreenUpdating = False

Sheets("X").Visible = True
Sheets("X").Select
Columns("A:A").ClearContents

Sheets("FOR SBH ONLY").Columns("B:B").Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
..
..
..
and so on

hth

Greetings Carlo

"Susan" wrote:

1st post, btw.........
i've read a lot of advice from you wonderful MVP people advising
against having a macro "select" cells all the time, for the sake of
saving time. i don't understand exactly how you write the code without
selecting things............. could you pls. amend this code below so
that i can see how you write it without selecting things?
(pls. excuse it the code - i'm sure it could be written much more
neatly but i'm still learning! like i realize all the "extra" parts of
the paste special can be deleted - just haven't got there yet!)
thanks very much! :D
susan
----------------
Sub UpdateCount()
'
' UpdateCount Macro
' Macro recorded 1/23/2006 by Susan
'
' revised 9/19/2006 to hide "X" worksheet
'
Application.ScreenUpdating = False

Sheets("X").Visible = True
Sheets("X").Select
Columns("A:A").Select

Selection.ClearContents

Range("A1").Select
Sheets("FOR SBH ONLY").Select
Columns("B:B").Select
Selection.Copy
Sheets("X").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False

Range("A1").Select
Application.CutCopyMode = False
Selection.ClearContents

Cells.Replace What:="contractor", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="inspectors:", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="general:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="electric:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="furnace & plumbing:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="wells & excavation:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="septic:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="sub-s:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

Columns("A:A").Select

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("D3").Select

ActiveWindow.SelectedSheets.Visible = False
Sheets("FOR SBH ONLY").Select
Range("A1").Select

Application.ScreenUpdating = True

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default newsgroup advice "selecting"

On 20 Sep 2006 04:55:59 -0700, "Susan" wrote:

1st post, btw.........
i've read a lot of advice from you wonderful MVP people advising
against having a macro "select" cells all the time, for the sake of
saving time. i don't understand exactly how you write the code without
selecting things............. could you pls. amend this code below so
that i can see how you write it without selecting things?
(pls. excuse it the code - i'm sure it could be written much more
neatly but i'm still learning! like i realize all the "extra" parts of
the paste special can be deleted - just haven't got there yet!)
thanks very much! :D
susan


You just reference the cells directly. See below


----------------
Sub UpdateCount()
'
' UpdateCount Macro
' Macro recorded 1/23/2006 by Susan
'
' revised 9/19/2006 to hide "X" worksheet
'
Application.ScreenUpdating = False

Sheets("X").Visible = True
XXX Sheets("X").Select
XXX Columns("A:A").Select

XXX Selection.ClearContents


Sheets("X").Columns("A:A").ClearContents


XXX Range("A1").Select
XXX Sheets("FOR SBH ONLY").Select
XXX Columns("B:B").Select
XXX Selection.Copy


Sheets("FOR SBH ONLY").Columns("B:B").Copy


You should be able to figure the rest out from these examples



Sheets("X").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False

Range("A1").Select
Application.CutCopyMode = False
Selection.ClearContents

Cells.Replace What:="contractor", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="inspectors:", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="general:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="electric:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="furnace & plumbing:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="wells & excavation:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="septic:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="sub-s:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

Columns("A:A").Select

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("D3").Select

ActiveWindow.SelectedSheets.Visible = False
Sheets("FOR SBH ONLY").Select
Range("A1").Select

Application.ScreenUpdating = True

End Sub


--ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default newsgroup advice "selecting"

try this. Since it's long and I didn't test so I may have missed something.

with Sheets("X")
.. Columns(1).ClearContents

..columns(1).value= Sheets("FOR SBH ONLY").Columns(2).value
.. Cells.Replace What:="contractor", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
.. Cells.Replace What:="inspectors:", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
.. Cells.Replace What:="general:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
.. Cells.Replace What:="electric:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
.. Cells.Replace What:="furnace & plumbing:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
.. Cells.Replace What:="wells & excavation:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
.. Cells.Replace What:="septic:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
.. Cells.Replace What:="sub-s:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

. Columns("A:A").Sort Key1:=.Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

end with


--
Don Guillett
SalesAid Software

"Susan" wrote in message
oups.com...
1st post, btw.........
i've read a lot of advice from you wonderful MVP people advising
against having a macro "select" cells all the time, for the sake of
saving time. i don't understand exactly how you write the code without
selecting things............. could you pls. amend this code below so
that i can see how you write it without selecting things?
(pls. excuse it the code - i'm sure it could be written much more
neatly but i'm still learning! like i realize all the "extra" parts of
the paste special can be deleted - just haven't got there yet!)
thanks very much! :D
susan
----------------
Sub UpdateCount()
'
' UpdateCount Macro
' Macro recorded 1/23/2006 by Susan
'
' revised 9/19/2006 to hide "X" worksheet
'
Application.ScreenUpdating = False

Sheets("X").Visible = True
Sheets("X").Select
Columns("A:A").Select

Selection.ClearContents

Range("A1").Select
Sheets("FOR SBH ONLY").Select
Columns("B:B").Select
Selection.Copy
Sheets("X").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False

Range("A1").Select
Application.CutCopyMode = False
Selection.ClearContents

Cells.Replace What:="contractor", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="inspectors:", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="general:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="electric:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="furnace & plumbing:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="wells & excavation:", Replacement:="",
LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="septic:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="sub-s:", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

Columns("A:A").Select

Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("D3").Select

ActiveWindow.SelectedSheets.Visible = False
Sheets("FOR SBH ONLY").Select
Range("A1").Select

Application.ScreenUpdating = True

End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default newsgroup advice "selecting"

thanks all so much...... now that i can SEE what you mean versus what i
wrote, i understand what you're saying.
thanks!
susan

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
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Advice needed: "Portable" macros? durex Excel Programming 2 October 6th 05 11:43 PM


All times are GMT +1. The time now is 03:50 AM.

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"