Solved

Convert cell value to cell comment

Posted on 2015-01-09
3
156 Views
Last Modified: 2015-01-09
Hello,

i need help with VBA,

on selection of a range, i want to run a macro that moves each cell value to cell comment and erases the cells and puts 1 in each of those cells.

thanks.
0
Comment
Question by:Flora
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 250 total points
ID: 40539899
Hi,

pls try

Sub macro1()

For Each c In Selection
    Set cmt = c.Comment
    If cmt Is Nothing Then
        c.AddComment
    End If
    c.Comment.Text Text:=CStr(c.Value)
    c.Value = 1
Next
End Sub

Open in new window

Regards

EDIT test if already a comment
0
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 250 total points
ID: 40539903
Sub Convert()
Dim strString As String
For Each myCell In Selection
    If myCell.Value <> "" Then
    myCell.AddComment
    myCell.Comment.Visible = False
    strString = myCell.Value
    myCell.Comment.Text Text:=strString
    myCell.Value = "1"
    End If
Next
End Sub

Open in new window

0
 
LVL 6

Author Closing Comment

by:Flora
ID: 40539907
both codes were excelent

thank you both.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question