copy/paste column remove formulas

  • Thread starter Thread starter sugargenius
  • Start date Start date
S

sugargenius

I need to copy a column and paste it special to remove formulas. The
columns position is variable.

here's what i've tried so far

*--remove formula for totals
IF lnTotalColumn > 1
loXLSheet.Columns(lnTotalColumn).Copy
*!* loXLSheet.Range(Get_Col(lnTotalColumn)+
"1").PasteSpecial(xlPasteValues)
*!* loXLSheet.Columns(lnTotalColumn).PasteSpecial(xlPasteValues)
loXLSheet.Range(Get_Col(lnTotalColumn)+ "1").Select
loXLSheet.Application.Selection.PasteSpecial(xlPasteValues)
ENDIF


Most threw error:
OLE IDispatch exception code 0 from Microsoft Office Excel: This
operation requires the merged cells to be identically sized... (1429)

I'd rather not use selection.
 
Sub columntovalues()
Columns("m").Value = Columns("m").Value
End Sub
or
Columns(activecell.column).Value = Columns(activecell.column).Value
 
Don said:
Sub columntovalues()
Columns("m").Value = Columns("m").Value
End Sub
or
Columns(activecell.column).Value = Columns(activecell.column).Value

Thanks for the suggestion Don. It doesn't work via OLE for some
reason. I get error

Array dimensions are invalid. (230)

If I loop through each cell, it works:

FOR x=4 TO loXLSheet.Cells(65536, lnTotalColumn).End(xlUp).Row
loXLSheet.Cells(x,lnTotalColumn).Value =
loXLSheet.Cells(x,lnTotalColumn).Value
ENDFOR
 

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