Solved

Excel vba to place field name from another worksheet into a different cell/worksheet

Posted on 2014-09-30
4
59 Views
Last Modified: 2016-02-11
Hi Experts,

I have some script that I have copied from textpad and pasted into excel.  I need to update the script incrementally where it says "samp1" below and I need to change the select statement in that script as well.  I have all of the field names pasted in one column in sheet2 of my excel workbook and the script is pasted on sheet1.  See example below:

Sheet 1

samp1.abc
samp1.123
samp1.nowIknow
samp1.sql=select * from "the first name in cell a1 on sheet2"

samp2.abc
samp2.123
samp2.nowIknow
samp2.sql=select * from "the first name in cell a2 on sheet2"

samp3.abc
samp3.123
samp3.nowIknow
samp3.sql=select * from "the first name in cell a3 on sheet2"
0
Comment
Question by:daintysally
[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
  • 2
4 Comments
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40353268
can give more details, perhaps an example file?
0
 
LVL 20

Accepted Solution

by:
ElrondCT earned 500 total points
ID: 40356261
Are you looking for something like this?
Sub OutputLines()
    For i = 1 To 5
        Cells(i * 5, 1).Formula = "samp" & i & ".abc"
        Cells(i * 5 + 1, 1).Formula = "samp" & i & ".123"
        Cells(i * 5 + 2, 1).Formula = "samp" & i & ".nowIknow"
        Cells(i * 5 + 3, 1).Formula = "samp" & i & ".sql=select * from ""the first name in cell a" & i & " on sheet2"""
    Next i
End Sub

Open in new window

0
 

Author Comment

by:daintysally
ID: 40357448
@ElrondCT...yes, that is what I am aiming for
0
 

Author Closing Comment

by:daintysally
ID: 40789734
Thank you, this put me on the right path
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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
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…

728 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