Format problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Below is a piece of my code:

If Cell.Offset(0, -1).Value <> "Comment:" Then
WSSD.Cells(rw, "A") = Cell.Offset(0, -1)
WSSD.Cells(rw, "A").InsertIndent 3
rw = rw + 1
End If


My problem is that I want WSSD.Cells(rw,"A") to have the same format as
Cell.Offset(0,-1). However, I want to do this without copying and pasteing,
selecting or activating. Is that possible?
 
There are a lot of formatting options that you'd have to assign. Font size/font
name/italics, underlining, fill color, borders....

If you know exactly which of those you want to use, then you could just assign
them in code:

CellA.numberformat = cellb.numberformat
cellA.font.name = cellb.font.name
cellA.font.size = cellb.font.size
....and so forth

Why not just
cellb.copy
cella.pastespecial paste:=xlpasteformats
 
Below is a piece of my code:

If Cell.Offset(0, -1).Value <> "Comment:" Then
WSSD.Cells(rw, "A") = Cell.Offset(0, -1)
WSSD.Cells(rw, "A").InsertIndent 3
rw = rw + 1
End If


My problem is that I want WSSD.Cells(rw,"A") to have the same format as
Cell.Offset(0,-1). However, I want to do this without copying and pasteing,
selecting or activating. Is that possible?

If you don't want to copy/paste, and I'm not sure why you want to avoid that,
you could do something like:

with WSSD.Cells(rw,"A")
.numberformat = cell.offset(0,-1)
and so on for all of the other formatted parameters.

It would seem simpler to do something like

cell.offset(0,-1).copy
wssd.cells(rw,"A").PasteSpecial Paste:=xlPasteFormats


--ron
 
If you don't want to copy/paste, and I'm not sure why you want to avoid that,
you could do something like:

with WSSD.Cells(rw,"A")
.numberformat = cell.offset(0,-1)
and so on for all of the other formatted parameters.

It would seem simpler to do something like

cell.offset(0,-1).copy
wssd.cells(rw,"A").PasteSpecial Paste:=xlPasteFormats


--ron

Ooops, that should have been:

with WSSD.Cells(rw,"A")
.numberformat = cell.offset(0,-1).numberformat
and so on for all of the other formatted parameters.
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top