Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Techguy Sr eng.   on Nov 04 In MS Office Category.

  
Question Answered By: William Bouchard   on Nov 04

Sorry to have taken ages to look at this. Just too much to do.

The following macro will do it. This takes info from the Active sheet  and
copies A and E to Sheet 2 where E is not blank.

It is probably not the most concise code  but that makes it easier to change.

Sub copySelectedItems()

Dim SourceSheet As Worksheet
Dim TargetSheet As Worksheet
Dim SourceRow As Long
Dim TargetRow As Long
Dim Data_Rows As Long



Set SourceSheet = ActiveSheet
Set TargetSheet = Sheets("Sheet2")

SourceSheet.Range("A1").Select

Selection.End(xlDown).Select
Data_Rows = Selection.Row

TargetRow = 1
For SourceRow = 1 To Data_Rows
If (SourceSheet.Range("E" & SourceRow) = 0) Then
Else
TargetSheet.Range("A" & TargetRow).Value = SourceSheet.Range("A" &
SourceRow).Value
TargetSheet.Range("E" & TargetRow).Value = SourceSheet.Range("E" &
SourceRow).Value
TargetRow = TargetRow + 1
End If
Next

End Sub

Share: 

 
 
Didn't find what you were looking for? Find more on code help Or get search suggestion and latest updates.


Tagged: