Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default SOS VBA Code Emergency: need to copy tell to empty cell direct below where values in adjacent cells in different column are equal to each other.

I have an eight-column Excel (for Mac, but don't think that matters)
sheet (i.e., columns "A" -"H") and am trying to write a macro that
will look down the cells in Column "H" (about 10,000 rows of data)
and, upon finding an empty cell ("target cell"), copy the contents
(text) from the cell directly above that cell IF:

--the "target" cell is empty; AND
--the value of the same-row cells over in column "D" equal each other.

In other words, an example:

IF. in Column "H", Row 26 has a value of "Judge12", and Row 27 is
empty, the macro should copy "Judge 12" from Row 26 to Row 27 in
Column "H"
AS LONG AS Rows 26 and 27 Column "D" both have the same value, e.g.,
"Smith."
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SOS VBA Code Emergency: need to copy tell to empty cell direct below where values in adjacent cells in different column are equal to each other.

Sub AAFillrow()
Dim rng As Range
Dim cell As Range
Set rng = Columns(8).SpecialCells(xlBlanks)
For Each cell In rng
If cell.Offset(0, -4).Value = cell.Offset(-1, -4).Value Then
cell.Value = cell.Offset(-1, 0).Value
End If
Next

End Sub

Should do what you want.

--
Regards,
Tom Ogilvy




Steven Rosenberg wrote in message
om...
I have an eight-column Excel (for Mac, but don't think that matters)
sheet (i.e., columns "A" -"H") and am trying to write a macro that
will look down the cells in Column "H" (about 10,000 rows of data)
and, upon finding an empty cell ("target cell"), copy the contents
(text) from the cell directly above that cell IF:

--the "target" cell is empty; AND
--the value of the same-row cells over in column "D" equal each other.

In other words, an example:

IF. in Column "H", Row 26 has a value of "Judge12", and Row 27 is
empty, the macro should copy "Judge 12" from Row 26 to Row 27 in
Column "H"
AS LONG AS Rows 26 and 27 Column "D" both have the same value, e.g.,
"Smith."



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default SOS VBA Code Emergency: need to copy tell to empty cell direct below where values in adjacent cells in different column are equal to each other.

Hi Steven,

This should get you started

Sub conditional_copy()
Dim cell As Range
' assumes that you have selected all cells in col H
' where you want to copy contents

For Each cell In Selection
If cell = "" Then
If cell.Offset(0, -4) = cell.Offset(-1, -4) Then
cell.Offset(-1, 0).Copy Destination:=cell
End If
End If
Next cell

--
Ed Ferrero
http://edferrero.m6.net


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default SOS VBA Code Emergency: need to copy tell to empty cell direct below where values in adjacent cells in different column are equal to each other.

Well, thanks for the two suggested answers, but each
one results in "Compile Error" and "Syntax error", with
the "If cell" line, and the following line displayed in red
on my Mac in the edit box.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SOS VBA Code Emergency: need to copy tell to empty cell direct below where values in adjacent cells in different column are equal to each other.

Those are two separate lines of code - so both shouldn't be highlighted in
red. Sounds like you have some problem with the entry of the code in the
module. I can't imagine the MAC wouldn't support the code in either -
particularly those lines of code.

Regards,
Tom Ogilvy


Steven Rosenberg wrote in message
...
Well, thanks for the two suggested answers, but each
one results in "Compile Error" and "Syntax error", with
the "If cell" line, and the following line displayed in red
on my Mac in the edit box.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





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 SUM entire column, but only when adjacent cell is not empty SteveDJ Excel Worksheet Functions 3 May 7th 10 09:16 PM
To copy values in a column relevant to text in an adjacent column? Guy Keon Excel Worksheet Functions 2 November 15th 05 08:10 PM
Copy empty cells from one workbook to another - Code Dave Peterson Excel Discussion (Misc queries) 1 September 23rd 05 02:10 PM
lineup equal values by inserting empty cells uffe1909 Excel Discussion (Misc queries) 2 September 21st 05 01:39 PM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? SROSENYC Excel Programming 1 August 5th 03 04:34 AM


All times are GMT +1. The time now is 01:54 AM.

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

About Us

"It's about Microsoft Excel"