ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to copy a cell contains formula to a range (https://www.excelbanter.com/excel-programming/412024-macro-copy-cell-contains-formula-range.html)

Frank Situmorang[_2_]

Macro to copy a cell contains formula to a range
 
Sub hfscopy()
'
' purpose is to copy cell AI4 to Range AI 8 upto AI filled in the message
box "copy to this row", but it stuck in .Range("AI4").Copy
Destination:=Range("AI8:AI & CopyToThisRow") with highlight in yelllow.

I appreciate for any help


Dim CopyToThisRow As Long
CopyToThisRow = InputBox("Isi disini.... sampai cell dari kolunm AI no
berapa?")
If IsNumeric(CopyToThisRow) Then
With Worksheets("PO_Line_text")
If CopyToThisRow 8 And CopyToThisRow <= .Rows.Count Then
.Range("AI4").Copy Destination:=Range("AI8:AI & CopyToThisRow")
.Range("AI8:AI" & CopyToThisRow).Select
Exit Sub
End If
End With
End If
MsgBox "Kamu tidak mengisi no cell yang benar"
End Sub

--
H. Frank Situmorang

joel

Macro to copy a cell contains formula to a range
 
Variable should not be inside strings with double quotes. fix thjis is two
places in the code.

from
"AI8:AI & CopyToThisRow"
to
"AI8:AI" & CopyToThisRow


"Frank Situmorang" wrote:

Sub hfscopy()
'
' purpose is to copy cell AI4 to Range AI 8 upto AI filled in the message
box "copy to this row", but it stuck in .Range("AI4").Copy
Destination:=Range("AI8:AI & CopyToThisRow") with highlight in yelllow.

I appreciate for any help


Dim CopyToThisRow As Long
CopyToThisRow = InputBox("Isi disini.... sampai cell dari kolunm AI no
berapa?")
If IsNumeric(CopyToThisRow) Then
With Worksheets("PO_Line_text")
If CopyToThisRow 8 And CopyToThisRow <= .Rows.Count Then
.Range("AI4").Copy Destination:=Range("AI8:AI & CopyToThisRow")
.Range("AI8:AI" & CopyToThisRow).Select
Exit Sub
End If
End With
End If
MsgBox "Kamu tidak mengisi no cell yang benar"
End Sub

--
H. Frank Situmorang


Frank Situmorang[_2_]

Macro to copy a cell contains formula to a range
 
Thanks Joel, it works perfectly, you are awesome.

--
H. Frank Situmorang


"Joel" wrote:

Variable should not be inside strings with double quotes. fix thjis is two
places in the code.

from
"AI8:AI & CopyToThisRow"
to
"AI8:AI" & CopyToThisRow


"Frank Situmorang" wrote:

Sub hfscopy()
'
' purpose is to copy cell AI4 to Range AI 8 upto AI filled in the message
box "copy to this row", but it stuck in .Range("AI4").Copy
Destination:=Range("AI8:AI & CopyToThisRow") with highlight in yelllow.

I appreciate for any help


Dim CopyToThisRow As Long
CopyToThisRow = InputBox("Isi disini.... sampai cell dari kolunm AI no
berapa?")
If IsNumeric(CopyToThisRow) Then
With Worksheets("PO_Line_text")
If CopyToThisRow 8 And CopyToThisRow <= .Rows.Count Then
.Range("AI4").Copy Destination:=Range("AI8:AI & CopyToThisRow")
.Range("AI8:AI" & CopyToThisRow).Select
Exit Sub
End If
End With
End If
MsgBox "Kamu tidak mengisi no cell yang benar"
End Sub

--
H. Frank Situmorang



All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com