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

Saludos...

What would the code in vba be for the following , Kind of new vba and stil
haven't got the hang of loops.

I have a sheet the looks like the following. How can I make it so it copies
CODE1 in the blank cells till it reaches code2 , then copy code 2 in the
blank cells between code2 and 3 and so on.

a b c
Code 1 Juan 22 days
Pedro 14 hrs
Luis 15 day

Code 2 Juan 5 days
Pedro 3 hrs
Luis 2 day

Code 3 Juan 2 days

and so on.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default coping cells

You can do it pretty easily by hand... Assuming Code 1 is in Cell A1 add this
formula to A2 =if(b2<"", A1, ""). Now copy Cell A2. Highlight A1:A100 (or
however far you need to go) and hit F5 -Special Cells - Blanks - OK (all
of the blanks in A1:A100 will now be selected) Paste the formula into the
blanks... Now Copy column A and paste speacial values. if you need a macro to
do this just record your actions while you do it...
--
HTH...

Jim Thomlinson


"JJMNZ76" wrote:

Saludos...

What would the code in vba be for the following , Kind of new vba and stil
haven't got the hang of loops.

I have a sheet the looks like the following. How can I make it so it copies
CODE1 in the blank cells till it reaches code2 , then copy code 2 in the
blank cells between code2 and 3 and so on.

a b c
Code 1 Juan 22 days
Pedro 14 hrs
Luis 15 day

Code 2 Juan 5 days
Pedro 3 hrs
Luis 2 day

Code 3 Juan 2 days

and so on.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default coping cells

Just modify ranges as needed:

Sub SameAsAbove()
'Copies data from cell above if current cell in range is blank
Dim MyRange As Range
Dim MyCell As Range
Dim Endrow As Integer
Endrow = Range("A65536").End(xlUp).Row
Set MyRange = Range("A1:G" & Endrow)
MyRange.Select
On Error Resume Next
For Each MyCell In MyRange
If MyCell.Value = "" Then
MyCell.Value = MyCell.Offset(-1, 0).Value
End If
Next MyCell
End Sub

JJMNZ76 wrote:
Saludos...

What would the code in vba be for the following , Kind of new vba and stil
haven't got the hang of loops.

I have a sheet the looks like the following. How can I make it so it copies
CODE1 in the blank cells till it reaches code2 , then copy code 2 in the
blank cells between code2 and 3 and so on.

a b c
Code 1 Juan 22 days
Pedro 14 hrs
Luis 15 day

Code 2 Juan 5 days
Pedro 3 hrs
Luis 2 day

Code 3 Juan 2 days

and so on.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default coping cells

Debra Dalgleish has some techniques:
http://www.contextures.com/xlDataEntry02.html



JJMNZ76 wrote:

Saludos...

What would the code in vba be for the following , Kind of new vba and stil
haven't got the hang of loops.

I have a sheet the looks like the following. How can I make it so it copies
CODE1 in the blank cells till it reaches code2 , then copy code 2 in the
blank cells between code2 and 3 and so on.

a b c
Code 1 Juan 22 days
Pedro 14 hrs
Luis 15 day

Code 2 Juan 5 days
Pedro 3 hrs
Luis 2 day

Code 3 Juan 2 days

and so on.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default coping cells

Thanks to all,

"Dave Peterson" wrote:

Debra Dalgleish has some techniques:
http://www.contextures.com/xlDataEntry02.html



JJMNZ76 wrote:

Saludos...

What would the code in vba be for the following , Kind of new vba and stil
haven't got the hang of loops.

I have a sheet the looks like the following. How can I make it so it copies
CODE1 in the blank cells till it reaches code2 , then copy code 2 in the
blank cells between code2 and 3 and so on.

a b c
Code 1 Juan 22 days
Pedro 14 hrs
Luis 15 day

Code 2 Juan 5 days
Pedro 3 hrs
Luis 2 day

Code 3 Juan 2 days

and so on.


--

Dave Peterson

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
Retain Format When Coping Visible Cells Only to New Worksheet Ronster Excel Programming 5 January 12th 06 09:19 PM
Macro for coping cells from one worksheet to another ShahAFFS Excel Programming 3 August 31st 05 11:28 AM
Coping numbers only in cells to other worksheets. Barracuda Excel Programming 1 June 20th 05 04:54 AM
Trouble Coping Visible Cells JenYancey Excel Discussion (Misc queries) 2 May 25th 05 12:17 AM
Coping all cells with data. Pete Excel Programming 0 January 8th 04 09:40 PM


All times are GMT +1. The time now is 11:44 AM.

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"