Solved

Excel Spreadsheet Macro Question

Posted on 2002-04-05
6
369 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now