LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Range returning info from wrong sheet

I have multiple sheets in a workbook that are similar. They track new
projects as they are received.
They all have a command button to call a macro that is in each sheet.
Every day I make copies of this worksheet as new projects arrive and
they are all located in the same workbook. There probably is a better
place to have this code stored but it is in each sheet.

The problem I am having is that the range() values are not always
referencing the information on the current sheet where the command
button was clicked.
At times it looks at the previous sheets cell information and puts it
in the current sheets output. I have to exit excel and restart to get
the correct range information.

How can I make it reference the current called sheet only?

Also where would be a better place to store this code - In a module?
And if so I assume I need to tell the command button on click to
reference the module macro. But how do I tell it to look at the range
info from the sheet the button was clicked?


here is part of the code:


Private Sub CommandButton2_Click()

Dim R, C As Integer

Dim client_contact, client, project, project_number, boring, depth,
sample, lab_Id, test, date_rec As String

client = Range("C4")
project = Range("c5")
project_number = Range("p11")
date_rec = Range("ak12")

Worksheets("input").Range("b3..b6").Value = "" 'clear range
Worksheets("input").Range("b10..k13").Value = "" 'clear range

Worksheets("input").Range("b3").Value = client
Worksheets("input").Range("b4").Value = project
Worksheets("input").Range("b5").Value = project_number
Worksheets("input").Range("b6").Value = date_rec

Etc.......

 
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
SUMPRODUCT Returning 0 or wrong totals Rbirdie Excel Worksheet Functions 12 May 7th 23 03:42 AM
Lookup info in one Column and then returning info in other columns Cyndi513 Excel Worksheet Functions 1 June 23rd 08 02:36 PM
Formula returning wrong answer Mike H Excel Worksheet Functions 1 September 14th 07 04:04 PM
OFFSET function in named range returning wrong # of rows Heidi Excel Worksheet Functions 5 March 20th 07 10:15 PM
VLOOKUP returning wrong row jthomas Excel Worksheet Functions 6 August 3rd 05 10:32 PM


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