Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

code help

  Asked By: Techguy    Date: Nov 04    Category: MS Office    Views: 665
  

My cells in column E have values that correspond to the name in column
A.

Certain cells have values, and some have no values.

I want to return the values of those cells in column e along with the
corresponding text in column a to another sheet in the same wrkbook.

Any advice? I just want the text in column a and the value in column
e. THe code should search for numbers present in column e and if so
return along with correspond a value to another sheet in the same
wrkbook.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: William Bouchard     Answered 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

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




Tagged: