Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default If sheet exists and it is named run this code

I would like to do the following. Can you assist?

If sheet exists and it is named 01,02,03,04,05,05a, then run this code

Dim lngRow As Long, blnInsert As Boolean
lngRow = 2
Do While lngRow <= Cells(Rows.Count, "G").End(xlUp).Row
blnInsert = Not blnInsert
If blnInsert Then
Rows(lngRow).Insert
Range("A" & lngRow) = Date - Range("H" & lngRow + 1)
End If
lngRow = lngRow + 1
Loop

If sheet exists and it is named
06,07,07a,08,09,10,10a,11,12,12a,13,13a,14,15,15a, then run this code

Dim dateRow As Long, emptInsert As Boolean
dateRow = 2
Do While dateRow <= Cells(Rows.Count, "G").End(xlUp).Row
emptInsert = Not emptInsert
If emptInsert Then
Rows(dateRow).Insert
Range("D" & dateRow) = Date - Range("K" & dateRow + 1)
End If
dateRow = dateRow + 1
Loop


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default If sheet exists and it is named run this code

Jazz, try the below

Dim lngRow As Long, blnInsert As Boolean
lngRow = 2
Select Case ActiveSheet.Name
Case "01", "02", "03", "04", "05", "05a", "06", _
"07", "07a", "08", "09", "10", "10a", "11", _
"12", "12a", "13", "13a", "14", "15", "15a"
Do While lngRow <= Cells(Rows.Count, "G").End(xlUp).Row
blnInsert = Not blnInsert
If blnInsert Then
Rows(lngRow).Insert
Select Case ActiveSheet.Name
Case "01", "02", "03", "04", "05", "05a"
Range("A" & lngRow) = Date - Range("H" & lngRow + 1)
Case "06", "07", "07a", "08", "09", "10", "10a", "11", _
"12", "12a", "13", "13a", "14", "15", "15a"
Range("D" & dateRow) = Date - Range("K" & dateRow + 1)
End Select
End If
lngRow = lngRow + 1
Loop
End Select

If this post helps click Yes
---------------
Jacob Skaria


"Jazz" wrote:

I would like to do the following. Can you assist?

If sheet exists and it is named 01,02,03,04,05,05a, then run this code

Dim lngRow As Long, blnInsert As Boolean
lngRow = 2
Do While lngRow <= Cells(Rows.Count, "G").End(xlUp).Row
blnInsert = Not blnInsert
If blnInsert Then
Rows(lngRow).Insert
Range("A" & lngRow) = Date - Range("H" & lngRow + 1)
End If
lngRow = lngRow + 1
Loop

If sheet exists and it is named
06,07,07a,08,09,10,10a,11,12,12a,13,13a,14,15,15a, then run this code

Dim dateRow As Long, emptInsert As Boolean
dateRow = 2
Do While dateRow <= Cells(Rows.Count, "G").End(xlUp).Row
emptInsert = Not emptInsert
If emptInsert Then
Rows(dateRow).Insert
Range("D" & dateRow) = Date - Range("K" & dateRow + 1)
End If
dateRow = dateRow + 1
Loop


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default If sheet exists and it is named run this code

Hi,

Here's on way

Sub Sonic()
Dim V As Variant
Dim S As String
Dim ws As Worksheet
'Change the next line to your worksheet names
S = "aaa,bbb,ccc,ddd,eee,fff,ggg,hhh"
V = Split(S, ",")
For Each ws In ActiveWorkbook.Worksheets
If Not IsError(Application.Match(CStr(ws.Name), V, 0)) Then

'your code goes here

End If
Next
End Sub



Mike

"Jazz" wrote:

I would like to do the following. Can you assist?

If sheet exists and it is named 01,02,03,04,05,05a, then run this code

Dim lngRow As Long, blnInsert As Boolean
lngRow = 2
Do While lngRow <= Cells(Rows.Count, "G").End(xlUp).Row
blnInsert = Not blnInsert
If blnInsert Then
Rows(lngRow).Insert
Range("A" & lngRow) = Date - Range("H" & lngRow + 1)
End If
lngRow = lngRow + 1
Loop

If sheet exists and it is named
06,07,07a,08,09,10,10a,11,12,12a,13,13a,14,15,15a, then run this code

Dim dateRow As Long, emptInsert As Boolean
dateRow = 2
Do While dateRow <= Cells(Rows.Count, "G").End(xlUp).Row
emptInsert = Not emptInsert
If emptInsert Then
Rows(dateRow).Insert
Range("D" & dateRow) = Date - Range("K" & dateRow + 1)
End If
dateRow = dateRow + 1
Loop


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default If sheet exists and it is named run this code

Thank you. I am thankful for your help.

"Jacob Skaria" wrote:

Jazz, try the below

Dim lngRow As Long, blnInsert As Boolean
lngRow = 2
Select Case ActiveSheet.Name
Case "01", "02", "03", "04", "05", "05a", "06", _
"07", "07a", "08", "09", "10", "10a", "11", _
"12", "12a", "13", "13a", "14", "15", "15a"
Do While lngRow <= Cells(Rows.Count, "G").End(xlUp).Row
blnInsert = Not blnInsert
If blnInsert Then
Rows(lngRow).Insert
Select Case ActiveSheet.Name
Case "01", "02", "03", "04", "05", "05a"
Range("A" & lngRow) = Date - Range("H" & lngRow + 1)
Case "06", "07", "07a", "08", "09", "10", "10a", "11", _
"12", "12a", "13", "13a", "14", "15", "15a"
Range("D" & dateRow) = Date - Range("K" & dateRow + 1)
End Select
End If
lngRow = lngRow + 1
Loop
End Select

If this post helps click Yes
---------------
Jacob Skaria


"Jazz" wrote:

I would like to do the following. Can you assist?

If sheet exists and it is named 01,02,03,04,05,05a, then run this code

Dim lngRow As Long, blnInsert As Boolean
lngRow = 2
Do While lngRow <= Cells(Rows.Count, "G").End(xlUp).Row
blnInsert = Not blnInsert
If blnInsert Then
Rows(lngRow).Insert
Range("A" & lngRow) = Date - Range("H" & lngRow + 1)
End If
lngRow = lngRow + 1
Loop

If sheet exists and it is named
06,07,07a,08,09,10,10a,11,12,12a,13,13a,14,15,15a, then run this code

Dim dateRow As Long, emptInsert As Boolean
dateRow = 2
Do While dateRow <= Cells(Rows.Count, "G").End(xlUp).Row
emptInsert = Not emptInsert
If emptInsert Then
Rows(dateRow).Insert
Range("D" & dateRow) = Date - Range("K" & dateRow + 1)
End If
dateRow = dateRow + 1
Loop


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default If sheet exists and it is named run this code

Your instruction is very much appreciated. Thank you a lot!

"Mike H" wrote:

Hi,

Here's on way

Sub Sonic()
Dim V As Variant
Dim S As String
Dim ws As Worksheet
'Change the next line to your worksheet names
S = "aaa,bbb,ccc,ddd,eee,fff,ggg,hhh"
V = Split(S, ",")
For Each ws In ActiveWorkbook.Worksheets
If Not IsError(Application.Match(CStr(ws.Name), V, 0)) Then

'your code goes here

End If
Next
End Sub



Mike

"Jazz" wrote:

I would like to do the following. Can you assist?

If sheet exists and it is named 01,02,03,04,05,05a, then run this code

Dim lngRow As Long, blnInsert As Boolean
lngRow = 2
Do While lngRow <= Cells(Rows.Count, "G").End(xlUp).Row
blnInsert = Not blnInsert
If blnInsert Then
Rows(lngRow).Insert
Range("A" & lngRow) = Date - Range("H" & lngRow + 1)
End If
lngRow = lngRow + 1
Loop

If sheet exists and it is named
06,07,07a,08,09,10,10a,11,12,12a,13,13a,14,15,15a, then run this code

Dim dateRow As Long, emptInsert As Boolean
dateRow = 2
Do While dateRow <= Cells(Rows.Count, "G").End(xlUp).Row
emptInsert = Not emptInsert
If emptInsert Then
Rows(dateRow).Insert
Range("D" & dateRow) = Date - Range("K" & dateRow + 1)
End If
dateRow = dateRow + 1
Loop


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
Reference two types of named sheet in a code Yossy Excel Programming 4 January 19th 09 09:42 AM
Check if a named range exists with VBA? [email protected] Excel Programming 3 January 31st 07 06:58 PM
Determining if a named range exists a Excel Programming 2 January 5th 06 01:39 PM
how to tell if a named range exists Gixxer_J_97[_2_] Excel Programming 2 June 1st 05 07:38 PM
Help with code that checks if a sheet exists wachen Excel Programming 2 February 10th 04 02:39 AM


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