Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Working on the wrong sheet


I am not able to manipulate data on the "Charts" worksheet.

I have three worksheets ("Charts", "Data", and "DataDown") in a single
workbook.
1. The "Charts" worksheet is where the final output needs to reside.
2. The "Data" worksheet is data copied from "DataDown" and another
workbook.
3. The "DownData" worksheet is a download of 49 columns.

I have entered the subroutine below on the "Data" worksheet. When the
sunroutine runs, it brings the "Charts" worksheet to the front but
manipulates the data on the "Data" sheet.

I need to be able to manipulate the data on the "Charts" worksheet from
the "Data" worksheet. I do not even need to bring the "Charts"
worksheet to the front.

I have lost my senses and cannot alter the data on "Charts".

Your thoughts are eagerly sought and appreciated!

Craigm

----------------------
Sub Acc_Types()

Dim wbBook As Workbook
Dim wsSheet As Worksheet

Dim rDescription 'Description
Column

Set wbBook = Workbooks("Charts_DataDown.xls")
Set wsSheet = wbBook.Sheets("Data")

Worksheets("Charts").Activate 'Move to "Charts" worksheet

'We are manipulating the DATA
Sheet NOT CHARTS sheet!
For Each rDescription In Range("A8:A10")
If rDescription.Value < "" Then
rDescription.Value = rDescription.Value & "9999;"
End If


Next rDescription

End Sub
-----------------------------------


--
Craigm
------------------------------------------------------------------------
Craigm's Profile: http://www.excelforum.com/member.php...o&userid=24381
View this thread: http://www.excelforum.com/showthread...hreadid=381733

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Working on the wrong sheet

Hi Craig,

OK, a few things. First, there is no need to Activate the "Charts"
Worksheet here, as you mentioned. Second, if your code resides behind the
"Data" Worksheet and you don't full-qualify your Range references (ie,
provide the Workbook and/or Worksheet object references), the Range objects
will always refer to "Data" Worksheet.

I would recommend using a standard code module instead of putting the code
behind a Worksheet. You can do what you're looking to do with this code:

Sub Acc_Types()
Dim rDescription As Range

For Each rDescription In Worksheets("Charts" _
).Range("A8:A10")
If rDescription.Value < "" Then
rDescription.Value = rDescription.Value & "9999;"
End If
Next rDescription
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Craigm wrote:
I am not able to manipulate data on the "Charts" worksheet.

I have three worksheets ("Charts", "Data", and "DataDown") in a single
workbook.
1. The "Charts" worksheet is where the final output needs to reside.
2. The "Data" worksheet is data copied from "DataDown" and another
workbook.
3. The "DownData" worksheet is a download of 49 columns.

I have entered the subroutine below on the "Data" worksheet. When the
sunroutine runs, it brings the "Charts" worksheet to the front but
manipulates the data on the "Data" sheet.

I need to be able to manipulate the data on the "Charts" worksheet
from the "Data" worksheet. I do not even need to bring the "Charts"
worksheet to the front.

I have lost my senses and cannot alter the data on "Charts".

Your thoughts are eagerly sought and appreciated!

Craigm

----------------------
Sub Acc_Types()

Dim wbBook As Workbook
Dim wsSheet As Worksheet

Dim rDescription
'Description Column

Set wbBook = Workbooks("Charts_DataDown.xls")
Set wsSheet = wbBook.Sheets("Data")

Worksheets("Charts").Activate 'Move to "Charts" worksheet

'We are manipulating the DATA
Sheet NOT CHARTS sheet!
For Each rDescription In Range("A8:A10")
If rDescription.Value < "" Then
rDescription.Value = rDescription.Value & "9999;"
End If


Next rDescription

End Sub
-----------------------------------


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Working on the wrong sheet

Move the code to a general module, not the sheet module of the Data sheet.
--
Regards,
Tom Ogilvy

"Craigm" wrote in
message ...

I am not able to manipulate data on the "Charts" worksheet.

I have three worksheets ("Charts", "Data", and "DataDown") in a single
workbook.
1. The "Charts" worksheet is where the final output needs to reside.
2. The "Data" worksheet is data copied from "DataDown" and another
workbook.
3. The "DownData" worksheet is a download of 49 columns.

I have entered the subroutine below on the "Data" worksheet. When the
sunroutine runs, it brings the "Charts" worksheet to the front but
manipulates the data on the "Data" sheet.

I need to be able to manipulate the data on the "Charts" worksheet from
the "Data" worksheet. I do not even need to bring the "Charts"
worksheet to the front.

I have lost my senses and cannot alter the data on "Charts".

Your thoughts are eagerly sought and appreciated!

Craigm

----------------------
Sub Acc_Types()

Dim wbBook As Workbook
Dim wsSheet As Worksheet

Dim rDescription 'Description
Column

Set wbBook = Workbooks("Charts_DataDown.xls")
Set wsSheet = wbBook.Sheets("Data")

Worksheets("Charts").Activate 'Move to "Charts" worksheet

'We are manipulating the DATA
Sheet NOT CHARTS sheet!
For Each rDescription In Range("A8:A10")
If rDescription.Value < "" Then
rDescription.Value = rDescription.Value & "9999;"
End If


Next rDescription

End Sub
-----------------------------------


--
Craigm
------------------------------------------------------------------------
Craigm's Profile:

http://www.excelforum.com/member.php...o&userid=24381
View this thread: http://www.excelforum.com/showthread...hreadid=381733



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Working on the wrong sheet


Does the sub need to be in the Data worksheet.

If you put it in a standard module it should run as you want.

Alternatively if you need to keep it in the Data worksheet you could
try specifying the Charts worksheet each time you want to manipulate
data on it.

ie, change:

For Each rDescription In Range("A8:A10")

to:

For Each rDescription In Sheets("Charts").Range("A8:A10")

If your code is in a particular worksheet it will act on that worksheet
unless explicitly to do otherwise.

HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381733

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Working on the wrong sheet


I simply copied the code into the general module for the workbook and i
runs correctly.

Outstanding, your comments were exacly on track.

Thank You

--
Craig
-----------------------------------------------------------------------
Craigm's Profile: http://www.excelforum.com/member.php...fo&userid=2438
View this thread: http://www.excelforum.com/showthread.php?threadid=38173

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
Vlookup-Wrong Sheet! BB New Users to Excel 9 August 5th 07 10:57 PM
Double clicking an Excel file is not working. What's wrong? VU2IM Excel Discussion (Misc queries) 3 June 8th 06 08:44 PM
I get wrong dates when i paste from a different sheet into a new s mmollat Excel Discussion (Misc queries) 2 January 6th 05 07:35 PM
Processing code on wrong sheet Jeff Klein Excel Programming 1 January 3rd 05 06:38 PM
Chart is being dumped into the wrong sheet poppy Excel Programming 5 July 29th 04 11:52 PM


All times are GMT +1. The time now is 11:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"