Convert cell value to cell comment

Posted on 2015-01-09
Last Modified: 2015-01-09

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.

Question by:Flora
LVL 49

Accepted Solution

Rgonzo1971 earned 250 total points
ID: 40539899

pls try

Sub macro1()

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

Open in new window


EDIT test if already a comment
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.Comment.Visible = False
    strString = myCell.Value
    myCell.Comment.Text Text:=strString
    myCell.Value = "1"
    End If
End Sub

Open in new window


Author Closing Comment

ID: 40539907
both codes were excelent

thank you both.

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Move data from one sheet to another 11 35
Clear Filter 8 40
sumifs excel 2013 3 15
Excel VBA - Constants 4 16
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

777 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