Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Excel Spreadsheet Macro Question

Posted on 2002-04-05
6
372 Views
Last Modified: 2008-03-17
I have a Macro that copies range I9:I22 from each sheet and pastes it to a summary sheet. The macro works great but when i go back to each sheet where the macro selected that range those cells are still black or selected. How do you write code into my macro to Unselect or unblacken those cells on each sheet?
Here is a copy of my macro.....

Sub Total_Hours()
Application.ScreenUpdating = False
Dim timesheet As Worksheet
    Dim Cell As Range
     For Each timesheet In ActiveWorkbook.Worksheets
        timesheet.Select
        Range("i9:i22").Select
        Selection.Copy
        Worksheets("total_hours").Activate
        ActiveCell.Offset(0, 1).PasteSpecial Paste:=xlValues
        Application.CutCopyMode = False
    Next
    Range("b1").Select
   
End Sub
0
Comment
Question by:He4Giv
6 Comments
 
LVL 32

Expert Comment

by:bhess1
ID: 6922115
Try Range(I9:i9).Activate - this should cancel the selection, and set the active cell to the top of the range.
0
 

Author Comment

by:He4Giv
ID: 6922292
That didnt work...Range("i9:i20").activate still shows that range on each worksheet as selected.
0
 
LVL 1

Accepted Solution

by:
nikelsh earned 50 total points
ID: 6922326
i thought after pasting u have to go again on the main sheet and select one of the cell. ie.

Sub Total_Hours()
Application.ScreenUpdating = False
Dim timesheet As Worksheet
   Dim Cell As Range
    For Each timesheet In ActiveWorkbook.Worksheets
       timesheet.Select
       Range("i9:i22").Select
       Selection.Copy
       Worksheets("total_hours").Activate
       ActiveCell.Offset(0, 1).PasteSpecial Paste:=xlValues
       Application.CutCopyMode = False
       timesheet.Select  ' select again
       Range("b1").Select ' any one cell in this sheet
   Next
   Range("b1").Select
     
End Sub

hope this will help u.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6922328
Try this:
Sub Total_Hours()
Application.ScreenUpdating = False
Dim timesheet As Worksheet
   Dim Cell As Range
    For Each timesheet In ActiveWorkbook.Worksheets
       with timesheet
            .Select
            .Range("i9:i22").Select
            Selection.Copy
            Worksheets("total_hours").Activate
            ActiveCell.Offset(0, 1).PasteSpecial Paste:=xlValues
           Application.CutCopyMode = False
           .range("A1").select
       End With
   Next
   Range("b1").Select
   
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6922330
oops!
Sorry...
....
.....
....
False
          .range("A1").Activate
      End With
  Next
  Range("b1").Select
 
End Sub
0
 

Author Comment

by:He4Giv
ID: 6922877
Works Great!!

Thank You
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question