View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default VBA Code to copy values &formats to the next worksheet

Dim rng as Range, cell as Range, cell1 as Range
set rng = Activesheet.UsedRange.SpecialCells(xlFormulas,xlNu mbers)
for each cell in rng
if cell.column < 5 and cell.column < 8 then
set cell1 = Worksheets("Sheet2").Range(cell.Address)
cell.copy
cell1.PasteSpecial xlValues
cell1.PasteSpecial xlFormats
end if
Next

--
Regards,
Tom Ogilvy

"bobby" wrote in message
ups.com...
Hi everybody,

I need a VBA code to copy the values in one sheet to the other
sheet. Here I'm giving my actual problem.

I have data in columns A to M which is generated by some conditional
formulas, if the condition is satisfied it will generate real values in
the cells if the condition is unsatisfied then the cell will display
"FALSE". Now what I need is a macro that copies only the cells which
are having values and paste to the other sheet spcecified and also I
need to copy column A to Column A ...So on, but I wnat to skip some
columns like E&H.

I got a macro in this group which copy and paste values&Formats to the
other sheet by selecting the range manually and then pasting the values
at the destination by running the macro.

The macro is like this.

Sub Pastesp()
with selection
pastespecial xlvalues
pastespecial xlformats
cutcopymode=false.
end sub.

can any body helpme to expand this code so that I can apply for my
specific problem.

Thanks and Regards

Ramana