macro that will copy ONLY the value I have in cell I1, and then paste it to another cell based on the cell reference I declared in cell G13

papajups

Board Regular
Joined
Sep 8, 2012
Messages
166
Good day All,


Hope all is well.

Could you please help me have a macro that will copy ONLY the value I have in cell I1, and then paste it to another cell based on the cell reference I declared in cell G13.

For example:

I1 = “expired”
G13 = C38

With this, I would like to see the value ‘expired’ in cell C38 when I run the macro.

Also, if the cell declared in G13 is already pre-occupied with value, then please do not run the macro but throw an error message like “The provided cell number is pre-occupied. Please check and try it again”.


I sincerely hope that you can help me on this. Thank you in advance!


regards,
Papajups
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this:
Code:
Sub MyCopy()

    Dim addy As String
    
'   Get cell address from cell G13
    addy = Range("G13").Value
    
'   Paste value from I1 to G13
    On Error GoTo err_chk
    If Range(addy) <> "" Then
        MsgBox "The provided cell number is pre-occupied. Please check and try it again"
    Else
        Range(addy) = Range("I1").Value
    End If
    On Error GoTo 0
    
    Exit Sub
    
err_chk:
    MsgBox "Invalid cell address in cell G13"
    
End Sub
 
Upvote 0
macro that will throw an error message if the cell reference I declared in cell G13 is outside of range C25:V74

Good day All,


Hope all is well.

I would like to ask for your help and expertise.

Is it possible to have a macro that will throw an error message if the cell reference I declared in cell G13 is outside of range C25:V74?

For example:

G13 = C24


Since, C24 is outside of C25:V74, then I should receive a message box like “Cell Reference is invalid”.


I hope you can assist me on this matter. Appreciate your help!


regards,
Papajups
 
Upvote 0
Re: macro that will throw an error message if the cell reference I declared in cell G13 is outside of range C25:V74

That's possible, but how is G13 being populated? If it's manual, then you could set up a DV rule without VBA. Also, check the macro Joe4 wrote for your other question. It included a check for validity, it can be also updated to check for a range.

Also, you seem to have several related questions. It might be easier to combine them to get a more connected answer.
 
Last edited:
Upvote 0
Re: macro that will throw an error message if the cell reference I declared in cell G13 is outside of range C25:V74

Think this is a duplicate post
 
Upvote 0
Re: macro that will throw an error message if the cell reference I declared in cell G13 is outside of range C25:V74

Did my code not answer your original question?
:confused:
 
Upvote 0
Re: macro that will throw an error message if the cell reference I declared in cell G13 is outside of range C25:V74

Related, evidently, but not a duplicate. Threads merged.

Evidently, i won't suggest duplicates again!
 
Upvote 0
Re: macro that will throw an error message if the cell reference I declared in cell G13 is outside of range C25:V74

Good day and happy New Year Joe,


Yes, your code works. You are a genius! Thank you so much for your help and kindness :)


regards,
Papajups
 
Upvote 0
Re: macro that will throw an error message if the cell reference I declared in cell G13 is outside of range C25:V74

That's possible, but how is G13 being populated? If it's manual, then you could set up a DV rule without VBA. Also, check the macro Joe4 wrote for your other question. It included a check for validity, it can be also updated to check for a range.

Also, you seem to have several related questions. It might be easier to combine them to get a more connected answer.

Good day Eric W,


Thank you for your response.

You are correct, cell G13 will populated manually. Could you please help me set-up a DV rule for this? I tried to search on the internet but can't find what I actually need.

Hope you can help me on this.


regards,
Papajups
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top