Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CJ CJ is offline
external usenet poster
 
Posts: 18
Default get cell value where offset cell = X, use this value to populate list

Example:

Sheet"xyz"
A B C D E F G H I
r x
s x
t x

Sheet"Titles"
A B C D E F G H I
r
s
t


IF worksheet name < "Titles" and value in column G = "x" THEN
for that same row, get the cell value in column D, and populate a
list in column A on worksheet name = "Titles"


THANK YOU for your help! I'm stuck.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default get cell value where offset cell = X, use this value to populate l

CJ,

Alt + F11 to open VB editor, right click 'This Workbook' and insert module,
paste this in and run it.

Sub copyit()
Dim MyRange, MyRange1 As Range
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
Set MyRange = Sheets("xyz").Range("G1:G" & lastrow)
Sheets("xyz").Select
For Each c In MyRange
If UCase(c.Value) = "X" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.Offset(, -6)
Else
Set MyRange1 = Union(MyRange1, c.Offset(, -6))
End If
End If
Next
If Not MyRange1 Is Nothing Then
MyRange1.Select
Selection.Copy
Sheets("Titles").Select
Range("A1").Select
ActiveSheet.Paste
End If
End Sub

Mike

"CJ" wrote:

Example:

Sheet"xyz"
A B C D E F G H I
r x
s x
t x

Sheet"Titles"
A B C D E F G H I
r
s
t


IF worksheet name < "Titles" and value in column G = "x" THEN
for that same row, get the cell value in column D, and populate a
list in column A on worksheet name = "Titles"


THANK YOU for your help! I'm stuck.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default get cell value where offset cell = X, use this value to populate l

OOPS,

the offset is -3 not minus -6 you wanted to copy column D

Mike

"CJ" wrote:

Example:

Sheet"xyz"
A B C D E F G H I
r x
s x
t x

Sheet"Titles"
A B C D E F G H I
r
s
t


IF worksheet name < "Titles" and value in column G = "x" THEN
for that same row, get the cell value in column D, and populate a
list in column A on worksheet name = "Titles"


THANK YOU for your help! I'm stuck.



  #4   Report Post  
Posted to microsoft.public.excel.programming
CJ CJ is offline
external usenet poster
 
Posts: 18
Default get cell value where offset cell = X, use this value to populatel

Thanks Mike! This worked for me below! Can you help me get this to
run for every worksheet in the active workbook where worksheet.name <
"TOC" or < "List"? Then with the data generated for each MyRange1, on
the "Title" worksheet append it to the next available row column A.
(Maybe leaving a space between each)


---------------------------------
Sub copyit()
Dim MyRange, MyRange1 As Range
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
Dim c As Range
Set MyRange = Sheets("xyz").Range("G12:G" & lastrow)
Sheets("xyz").Select

For Each c In MyRange
If c.Value = "Status:" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.Offset(, -3)
Else
Set MyRange1 = Union(MyRange1, c.Offset(, -3))
End If
End If
Next

If Not MyRange1 Is Nothing Then
MyRange1.Select
Selection.Copy
Sheets("Title").Select
Range("A1").Select
ActiveSheet.Paste
End If

End Sub
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default get cell value where offset cell = X, use this value to popula

As soon as I re-read your post i suspected you wanted it for every sheet so
try this

Sub copyit()
Dim MyRange, MyRange1 As Range
Dim ws As Worksheet
x = 1
For Each ws In ThisWorkbook.Worksheets
Worksheets(x).Select
If ws.Name < "Titles" And ws.Name < "TOC" Then
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
Set MyRange = Worksheets(x).Range("G1:G" & lastrow)
For Each c In MyRange
If UCase(c.Value) = "X" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.Offset(, -3)
Else
Set MyRange1 = Union(MyRange1, c.Offset(, -3))
End If
End If
Next
End If
If Not MyRange1 Is Nothing Then
MyRange1.Select
Selection.Copy
Sheets("Titles").Select
Cells(Cells(Rows.Count, "A").End(xlUp).Row, 1).Select
ActiveSheet.Paste
End If
x = x + 1
Set MyRange1 = Nothing
Next
Application.CutCopyMode = False
End Sub

Mike

"CJ" wrote:

Thanks Mike! This worked for me below! Can you help me get this to
run for every worksheet in the active workbook where worksheet.name <
"TOC" or < "List"? Then with the data generated for each MyRange1, on
the "Title" worksheet append it to the next available row column A.
(Maybe leaving a space between each)


---------------------------------
Sub copyit()
Dim MyRange, MyRange1 As Range
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
Dim c As Range
Set MyRange = Sheets("xyz").Range("G12:G" & lastrow)
Sheets("xyz").Select

For Each c In MyRange
If c.Value = "Status:" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.Offset(, -3)
Else
Set MyRange1 = Union(MyRange1, c.Offset(, -3))
End If
End If
Next

If Not MyRange1 Is Nothing Then
MyRange1.Select
Selection.Copy
Sheets("Title").Select
Range("A1").Select
ActiveSheet.Paste
End If

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default get cell value where offset cell = X, use this value to popula

I forgot the space between the rows add this line between the 2 existing lines

Cells(Cells(Rows.Count, "A").End(xlUp).Row, 1).Select

If ActiveCell.Row < 1 Then ActiveCell.Offset(2, 0).Select 'new line

ActiveSheet.Paste

Mike

"CJ" wrote:

Thanks Mike! This worked for me below! Can you help me get this to
run for every worksheet in the active workbook where worksheet.name <
"TOC" or < "List"? Then with the data generated for each MyRange1, on
the "Title" worksheet append it to the next available row column A.
(Maybe leaving a space between each)


---------------------------------
Sub copyit()
Dim MyRange, MyRange1 As Range
lastrow = Cells(Rows.Count, "G").End(xlUp).Row
Dim c As Range
Set MyRange = Sheets("xyz").Range("G12:G" & lastrow)
Sheets("xyz").Select

For Each c In MyRange
If c.Value = "Status:" Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.Offset(, -3)
Else
Set MyRange1 = Union(MyRange1, c.Offset(, -3))
End If
End If
Next

If Not MyRange1 Is Nothing Then
MyRange1.Select
Selection.Copy
Sheets("Title").Select
Range("A1").Select
ActiveSheet.Paste
End If

End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
CJ CJ is offline
external usenet poster
 
Posts: 18
Default get cell value where offset cell = X, use this value to popula

I get an error upon running for:

Selection.Copy

"That command cannot be used on multiple selections."
  #8   Report Post  
Posted to microsoft.public.excel.programming
CJ CJ is offline
external usenet poster
 
Posts: 18
Default get cell value where offset cell = X, use this value to popula

I get and error on

Selection.Copy

"cannot be used on multiple selections"

  #9   Report Post  
Posted to microsoft.public.excel.programming
CJ CJ is offline
external usenet poster
 
Posts: 18
Default get cell value where offset cell = X, use this value to popula

On Apr 21, 10:13 pm, CJ wrote:
I get an error upon running for:

Selection.Copy

"That command cannot be used on multiple selections."


This seems like it could be related to some of the columns with value
'X' are merged and others are not.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to populate cell based on drop-down list attached to the SAME cell? lpteague Excel Discussion (Misc queries) 1 October 4th 10 08:23 AM
Populate one cell with an offset cells contents Fleone Excel Programming 2 December 19th 07 09:47 PM
auto populate cell based on previous cell drop down list selectio. PuzzledbyLists Excel Discussion (Misc queries) 2 September 11th 06 01:28 AM
How can I make a list populate more than one cell in a row? Marcus Woods Excel Programming 5 August 25th 06 07:04 PM
Want to be able to click on a cell and have a list box appear to give values to populate a cell Richard Zellmer Excel Programming 2 September 16th 03 11:12 PM


All times are GMT +1. The time now is 11:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"