Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Darcy Jones   on Feb 22 In MS Office Category.

  
Question Answered By: Geb Chalthoum    on Feb 22

A few things:
Re:"I am getting error in it." and "But I got error while running."
Saying what error would be very helpful.

Re:"I put a MsgBox in the code  to catch the value. But it didn't show
anything."
This happens when there is nothing in the cell. Cells(7,2) refers to
cell 7 rows down and 2 columns across, ie. B7.

As your code stands it tries to add  (not concatenate) the following 4
things:

what it finds in row 7, "Y", what it finds in row 8, "M"

and it looks to row 2 to see how many columns it should process (I
imagine these are headers?). So as long as there's something in the
column in row 2 it tries to do the concatenating. When it reaches the
first empty cell in row 2 it stops looping.

Now all you need to do is change every instance of a '+' sign in the
code to a '&'. This should stop the Type mismatch error.

Cells(9, y).Value = Cells(7, y).Value & "Y" & Cells(8, y).Value & "M"

I note also that you have the line
x = 7
but never use x elsewhere.

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on VBA code to add values in two cells which have formulas Or get search suggestion and latest updates.


Tagged: