You are here:

Excel/Multiple Selection Changes?

Advertisement


Question
Hi,

I am trying to have more than one selection change in my spreadsheet but can't get it to work:

The first one is as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 8 Then
If Len(Trim(Target.Value)) <> 0 Then
Target.EntireRow.Copy Worksheets("Mentoring").Cells( _
  Rows.Count, "A").End(xlUp)(2)

2nd One I want:

If Target.Count > 1 Then Exit Sub
If Target.Column = 12 Then
If Len(Trim(Target.Value)) <> 0 Then
Target.EntireRow.Copy Worksheets("PSG").Cells( _
  Rows.Count, "A").End(xlUp)(2)
End If
End Sub


I also would like to add a 3rd if possible:

If Target.Count > 1 Then Exit Sub
If Target.Column = 10 Then
If Len(Trim(Target.Value)) <> 0 Then
Target.EntireRow.Copy Worksheets("Befriending").Cells( _
  Rows.Count, "A").End(xlUp)(2)


Thank you in advance for your help,

Hope it makes sense,

Rosie

Answer
Cells(Rows.Count, "A") is refers to column-A of the Sheets for finding the Last Row so the data you are copying should have a data in Column-A cell because the data will get pasted on the relevant sheet and when the process continues for the next time then due to non availability of data in column A cell (But data might be pasted earlier without any input in Column-A cell) the same row will be identified as last row (Eventhough It consist data in some other cell of the same row) and it overwrite it with the current data.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count > 1 Then Exit Sub

If Target.Column = 8 Then
   If Len(Trim(Target.Value)) <> 0 Then
       Target.EntireRow.Copy Worksheets("Mentoring").Cells( _
       Rows.Count, "A").End(xlUp)(2)
   End If
End If

If Target.Column = 12 Then
   If Len(Trim(Target.Value)) <> 0 Then
       Target.EntireRow.Copy Worksheets("PSG").Cells( _
       Rows.Count, "A").End(xlUp)(2)
   End If
End If

If Target.Column = 10 Then
   If Len(Trim(Target.Value)) <> 0 Then
       Target.EntireRow.Copy Worksheets("Befriending").Cells( _
       Rows.Count, "A").End(xlUp)(2)
   End If
End If

End Sub


Hope this helps!

---

Sixthsense
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Sixthsense

Expertise

[Overview] Having hands-on experience with Excel, I can able to answer questions which is related to Conditional Formatting, Goal Seek, Scenarios, Subtotal, Validation, Pivot Table, Shared Workbook, Excel Sheet / Workbook Protection, Excel Settings, Excel Shortcuts and the Two Major & Massive Key Areas of Excel (i.e.) Worksheet Functions and Excel VBA (Macro).

[Services] Volunteer in many of the Excel Discussion Groups / Forums and answered more than 10,000+ questions (approx.)

[Client FAQs] My Solution Files

[Not Interested In] Chart Questions

[Something Controversial]
*50% of answers never been read by the questioner's.
*Only 5% of questioner's provide feedback about the suggested answers.

Experience

Vast Experience

Education/Credentials
Ms-Office, Oracle, Foxpro, C, COBOL etc.,

©2016 About.com. All rights reserved.