Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro question


I receive an Excel workbook where the information I use is coupled into
two rows per item. The first row is the old information, and the second
row is the new information. If the new information is the same as the
old info, then nothing appears on the second row--the new information
cell is blank. This causes havoc with the macro I use to convert the
information so it becomes more easily usable and having the sender edit
the format is not an option.

Is there a function that I can insert into a macro so if the cell is
empty, then it will copy the cell from above it? For example, if S3 is
empty then it will copy the information from cell S2.

I know my terminology is off, so I apologize. My thanks in advance.


--
Cacoe
------------------------------------------------------------------------
Cacoe's Profile: http://www.excelforum.com/member.php...o&userid=28894
View this thread: http://www.excelforum.com/showthread...hreadid=486416

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default macro question

Hi Cacoe,

Try:
'==============
Public Sub Tester()
Dim Rng As Range

Set Rng = Selection '<<===== CHANGE

On Error Resume Next
Rng.SpecialCells(xlCellTypeBlanks).FormulaR1C1 _
= "=R[-1]C"
On Error GoTo 0

End Sub
'<<==============

---
Regards,
Norman


"Cacoe" wrote in
message ...

I receive an Excel workbook where the information I use is coupled into
two rows per item. The first row is the old information, and the second
row is the new information. If the new information is the same as the
old info, then nothing appears on the second row--the new information
cell is blank. This causes havoc with the macro I use to convert the
information so it becomes more easily usable and having the sender edit
the format is not an option.

Is there a function that I can insert into a macro so if the cell is
empty, then it will copy the cell from above it? For example, if S3 is
empty then it will copy the information from cell S2.

I know my terminology is off, so I apologize. My thanks in advance.


--
Cacoe
------------------------------------------------------------------------
Cacoe's Profile:
http://www.excelforum.com/member.php...o&userid=28894
View this thread: http://www.excelforum.com/showthread...hreadid=486416



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default macro question

Cacoe: here is one that should work:

'--------------------------------------------------------------------
' *** INSTRUCTIONS ***
'
' STEP 1
' Copy this into any Module in the workbook you want the Macro
' to be available in.
' STEP 2
' Select the entire range of cells you want to process:
' From your question, I would assume that area to be something
' like (S1 To S?20).
'
' STEP 4
' Run the macro 'CopyAbove' from the TOOLS...MACRO...MACROS Dialog
'
' That's it!!!
'--------------------------------------------------------------------
Public Sub CopyAbove()

Dim curRng As Range
Dim Evaluate As Range

Set Evaluate = Application.Selection
For Each curRng In Evaluate

If curRng.Row 1 Then

If curRng = "" And curRng.Offset(-1, 0) < "" Then

curRng = curRng.Offset(-1, 0)

End If

End If

Next curRng

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro question


Both work well. Thank you very much

--
Caco
-----------------------------------------------------------------------
Cacoe's Profile: http://www.excelforum.com/member.php...fo&userid=2889
View this thread: http://www.excelforum.com/showthread.php?threadid=48641

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
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Macro question Gilbert Excel Discussion (Misc queries) 7 November 8th 07 06:15 PM
Macro Question Carl Excel Worksheet Functions 5 February 10th 07 06:51 PM
Macro question John Excel Worksheet Functions 7 October 19th 06 04:48 PM
MACRO Question - Help Please!!!!!!!!!!!!!!!!! Frantic Excel-er Excel Discussion (Misc queries) 2 June 7th 05 03:43 PM


All times are GMT +1. The time now is 01:15 PM.

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"