ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying Cell Contents throughout spreadsheet (https://www.excelbanter.com/excel-programming/300212-copying-cell-contents-throughout-spreadsheet.html)

kaytee978

Copying Cell Contents throughout spreadsheet
 
I'm new with programming in Visual Basic, and I am attempting to cop
cell contents into the cells below it.

For example, we have a spreadsheet lists each location in a cell, (ex
A1) and then has numerous assets listed throughout until it gets to th
next location (ex. A39). How can I get the first cell to copy into al
the empty cells until it gets to the next location

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Copying Cell Contents throughout spreadsheet
 
select the column

Do edit =Goto Special and select Blanks

A2 should be the activeCell

in the formula bar type

=A1 then do Ctrl+Enter rather than Enter. This should fill all the blank
cells.

Now you can select column A and do Edit=Copy, then immediately
Edit=Pastespecial and select Values. This will replace the formulas with
the values they display.

--
Regards,
Tom Ogilvy

"kaytee978 " wrote in message
...
I'm new with programming in Visual Basic, and I am attempting to copy
cell contents into the cells below it.

For example, we have a spreadsheet lists each location in a cell, (ex.
A1) and then has numerous assets listed throughout until it gets to the
next location (ex. A39). How can I get the first cell to copy into all
the empty cells until it gets to the next location?


---
Message posted from http://www.ExcelForum.com/




kkknie[_123_]

Copying Cell Contents throughout spreadsheet
 
How about:

Code
-------------------
Sub test()

Dim i As Long
Dim iLastRow
Dim strLast As String

strLast = Range("A1").Value

'Assumes column B has data in the last row
iLastRow = Range("B65536").End(xlUp).Row

For i = 1 To iLastRow
'Checks for an empty cell
If Range("A" & i).Value = "" Then
Range("A" & i).Value = strLast
End If
strLast = Range("A" & i).Value
Next

End Su
-------------------

Assumptions:
- All of the A column cells are either blank or have data to be copie
down.
- Column B has data in the last row you want to copy to. If this i
not true, change from B65536 to C or D or wherever. If there is n
pattern, set iLastRow equal to the last row for data.



--
Message posted from http://www.ExcelForum.com


kaytee978[_2_]

Copying Cell Contents throughout spreadsheet
 
That worked perfectly! Thank you so much!

--
Message posted from http://www.ExcelForum.com



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com