Help with macro

Beekman

Board Regular
Joined
Nov 7, 2008
Messages
64
Option Explicit

Public Sub CopyBlockTwice()

Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet
Dim ws4 As Worksheet
Dim ws5 As Worksheet
Dim ws6 As Worksheet
Dim iLastRow As Long
Dim iRow As Long
Dim iOutRow As Long

Set ws1 = ThisWorkbook.Sheets("HEADER")
Set ws2 = ThisWorkbook.Sheets("MONDAY")
Set ws3 = ThisWorkbook.Sheets("TUESDAY")
Set ws4 = ThisWorkbook.Sheets("WEDNESDAY")
Set ws5 = ThisWorkbook.Sheets("THURSDAY")
Set ws6 = ThisWorkbook.Sheets("FRIDAY")

iLastRow = ws1.Range("B5").End(xlDown).Row

iOutRow = 10
For iRow = 5 To iLastRow
iOutRow = iOutRow + 1
ws1.Cells(iRow, "B").Copy Destination:=ws2.Cells(iOutRow, "A")
If ws1.Cells(iRow, "B").Value >= 4100 And ws1.Cells(iRow, "B").Value <= 4130 Then
iOutRow = iOutRow + 1
ws1.Cells(iRow, "B").Copy Destination:=ws2.Cells(iOutRow, "A")
End

This is part of macro. Bottom section i have repeated for Tusday to Friday
Macro works fine but needs a modification In the value 4100 and 4130 some will end in a letter such as 4125W. The macro does not copy twice values ending with a letter.

Can some one give me a modification to allow for this please.

Thanks, Ben
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try

Code:
If Val(Left(ws1.Cells(iRow, "B").Value, 4)) >= 4100 And Val(Left(ws1.Cells(iRow, "B").Value, 4)) <= 4130 Then
 
Upvote 0

Forum statistics

Threads
1,224,544
Messages
6,179,430
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top