Excel Macro to Insert the contents of one column to other

  • Thread starter Thread starter Dhawal
  • Start date Start date
D

Dhawal

Hello,

I have a worksheet in which my data is arranged as per temp. I have
Temp in one column and the corresponding value in the other. I need to
inser

For eg.
I have
temp 25C in two adjacent columns

i have to make it Temp: 25C

and remove the 25C from that column.

Can I get some help with the Excel Macro for the same.

Dhawal...
 
The easiest way would be to simply record the macro. Start the macro recorder
(Tools>Macros...), then execute the commands you need. Stop the recorder, and
save the macro with whatever name you want.
 
That Helps. But the data is uncertain so I have temp in many different
columns. There is more data below temp. I need some help with that.

Regards,
Dhawal
 
That Helps. But the data is uncertain so I have temp in many different
columns. There is more data below temp. I need some help with that.

Regards,
Dhawal
 
OK. Post the macro you have, then tell us what you need changed. That will be a
lot quicker than having everyone guess what your spreadsheet looks like.
 
Try this code - just be sure you're on the sheet you need to change things on
before using it - it works on the currently active/chosen sheet.

Sub CombineTemps()
Dim anyCell As Range

ActiveSheet.UsedRange.Select
For Each anyCell In Selection
If UCase(anyCell.Value) = "TEMP" Then
anyCell.Value = anyCell.Value & ": " & anyCell.Offset(0, 1).Value
anyCell.Offset(0, 1) = ""
End If
Next
End Sub
 

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