Sabtu, 04 April 2015

Re: [ExcelVBA] Re: Simple loop help


Please ALWAYS post your code - especially the line that gives the error.
I suspect that you have not used the "Set" keyword as you set CurrentCell.
> Also, I am trying to concatenate two cells, but retain their formats.
The .Value of a cell is exactly that ... a value.  It is not the format.
There is no standard way of combining two cells, including their formats.  What is in the two cells you are trying to combine?

Regards, Dave S
----- Original Message -----
Sent: Sunday, April 05, 2015 12:07 AM
Subject: [ExcelVBA] Re: Simple loop help

Something odd here. When I run it as "Dim CurrentCell As Long", it works fine, but when I change it to "Dim CurrentCell As Range", I get the error

Run-time error 91

Object variable or With block variable not set.

Also, I am trying to concatenate two cells, but retain their formats. I use:

For i = 1 To 52

      Cells(i, 4).Value = Cells(i, 2).Value & Cells(i, 3).Value
Next i

Cell (i,2) format is ok as is, but cell((i,3) font color is red. I would like to retain both formats after the concatenate. Any thoughts?

No virus found in this message.
Checked by AVG -
Version: 2015.0.5863 / Virus Database: 4321/9458 - Release Date: 04/05/15


Posted by: "David Smart" <>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (8)
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: to enter the ezine, then search the ARCHIVES for EXCEL VBA.

Visit our ExcelVBA group home page for more info and support files:

More free tutorials and resources available at:




Tidak ada komentar:

Posting Komentar