Solved

Convert cell value to cell comment

Posted on 2015-01-09
3
159 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 51

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

738 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