Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 11
Default VBA not selecting worksheet with titles

Hi,

I think its the late night but I would like some help with a code which I am struggling with.

To summarise my issue, I need this vba code to look at the worksheets which contains the words ", select a specific cell and paste some words.

Now I have got the last bit working but the main issue is that vba does not select the worksheet which contains ".
If the worksheets are called "testing1", "testing2", etc, I can get vba to work but its when I tell it to look for a sheet name containing "testing.com", it doesnt.

At the moment, the sheets are called , and


Sub ConsolidateHoldings()

Dim mysheet As Worksheet

Sheets("master").Select
Cells.Clear

For Each mysheet In Worksheets

mysheet.Select

If Left(mysheet.Name, 6) Like "testing.com" Then

Range("f2").Select
ActiveCell.FormulaR1C1 = "Hi,"
Range("f4").Select
ActiveCell.FormulaR1C1 = "Please review the data on the left"
Range("f6").Select
ActiveCell.FormulaR1C1 = "If this is incorrect, please advise?"
Range("f8").Select
ActiveCell.FormulaR1C1 = "Thanks"

End If

Next mysheet
Range("A1").Select

End Sub


Hopefully this is an easy fix but I would like some help please.

Thanks
Pri

P.s. sorry, I tried to load the excel file but I couldnt.

Last edited by Prets : February 4th 13 at 10:16 PM Reason: update to request
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,514
Default VBA not selecting worksheet with titles

Try...

Sub ConsolidateHoldings2()
Dim wks As Worksheet

Sheets("Master").Cells.Clear
For Each wks In ActiveWorkbook.Worksheets
If UCase$(Right(wks.Name, 11)) = "TESTING.COM" Then
With wks
.Range("F2") = "Hi"
.Range("F4") = "Please review the data on the left"
.Range("F6") = "If this is incorrect, please advise!"
.Range("F8") = "Thanks"
End With 'wks
End If
Next 'wks
End Sub 'ConsolidateHoldings2

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Junior Member
 
Posts: 11
Default

Hi Garry,

Thats perfect. Even better than I had originally planned.

Thank you so much.

Pri

Quote:
Originally Posted by GS[_2_] View Post
Try...

Sub ConsolidateHoldings2()
Dim wks As Worksheet

Sheets("Master").Cells.Clear
For Each wks In ActiveWorkbook.Worksheets
If UCase$(Right(wks.Name, 11)) = "TESTING.COM" Then
With wks
.Range("F2") = "Hi"
.Range("F4") = "Please review the data on the left"
.Range("F6") = "If this is incorrect, please advise!"
.Range("F8") = "Thanks"
End With 'wks
End If
Next 'wks
End Sub 'ConsolidateHoldings2

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,514
Default VBA not selecting worksheet with titles

You're welcome! Always glad to help...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
Y Axis Titles (Excel is clipping titles) al Excel Discussion (Misc queries) 4 April 14th 08 06:56 PM
Sorting a range on another worksheet without selecting the worksheet [email protected] Excel Programming 1 December 21st 06 11:06 PM
Are double lined worksheet tab titles possible? Igby Excel Discussion (Misc queries) 3 December 8th 06 10:36 AM
HOW DO I PRINT A LIST OF WORKSHEET TITLES FOR A SPECIFIC WORKBOOK beyondthevail Excel Discussion (Misc queries) 1 August 30th 06 04:58 PM
selecting cell range in other worksheet without switching to worksheet suzetter[_4_] Excel Programming 4 June 22nd 05 08:55 PM


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

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"