Vincent paul
New Member
- Joined
- Oct 8, 2014
- Messages
- 22
Hi,
I have a range with blank cells like this
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Store name[/TD]
[TD]Item 1[/TD]
[TD]Item 2[/TD]
[TD]Item 3[/TD]
[/TR]
[TR]
[TD]Store A[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Store B[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Store C[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Store D[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]
If blank cell is in between the range, code is not copying entire range.
Sub conc()
Dim myRow As Long
Dim storename As String
Dim myRange As Range
Dim cellrange As Range
Application.ScreenUpdating = False
Workbooks("E-shopaid Raw Data Jun'15.xlsx").Sheets("Comp").Activate
Range("A5").Select
Set myRange = Workbooks("E-shopaid Raw Data Jun'15.xlsx").Sheets("Comp").Range("A5")
Do Until myRange.Value = "Grand Total"
storename = myRange.Value
Set cellrange = Worksheets(storename).Range("B1")
If storename = cellrange Then
Range(myRange.Offset(0, 1), myRange.End(xlToRight)).Copy
ThisWorkbook.Activate
Worksheets(storename).Select
ActiveCell.PasteSpecial Paste:=xlPasteValues
Workbooks("E-shopaid Raw Data Jun'15.xlsx").Sheets("Comp").Activate
Set myRange = myRange.Offset(1, 0)
Else
MsgBox "Store name mismatch"
ActiveSheet.Next.Select
End If
Loop
End sub
Thanks..
I have a range with blank cells like this
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Store name[/TD]
[TD]Item 1[/TD]
[TD]Item 2[/TD]
[TD]Item 3[/TD]
[/TR]
[TR]
[TD]Store A[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Store B[/TD]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Store C[/TD]
[TD]1[/TD]
[TD][/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Store D[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]
If blank cell is in between the range, code is not copying entire range.
Sub conc()
Dim myRow As Long
Dim storename As String
Dim myRange As Range
Dim cellrange As Range
Application.ScreenUpdating = False
Workbooks("E-shopaid Raw Data Jun'15.xlsx").Sheets("Comp").Activate
Range("A5").Select
Set myRange = Workbooks("E-shopaid Raw Data Jun'15.xlsx").Sheets("Comp").Range("A5")
Do Until myRange.Value = "Grand Total"
storename = myRange.Value
Set cellrange = Worksheets(storename).Range("B1")
If storename = cellrange Then
Range(myRange.Offset(0, 1), myRange.End(xlToRight)).Copy
ThisWorkbook.Activate
Worksheets(storename).Select
ActiveCell.PasteSpecial Paste:=xlPasteValues
Workbooks("E-shopaid Raw Data Jun'15.xlsx").Sheets("Comp").Activate
Set myRange = myRange.Offset(1, 0)
Else
MsgBox "Store name mismatch"
ActiveSheet.Next.Select
End If
Loop
End sub
Thanks..