Solved

Excel Spreadsheet Macro Question

Posted on 2002-04-05
6
375 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
[X]
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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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